Title Outside writes to builtiin names of a module are not taken into account
Priority bug Status chatting
Superseder Nosy List kayhayen, thimo
Assigned To kayhayen Keywords

Created on 2015-04-15.16:08:41 by thimo, last changed by kayhayen.

msg1175 (view) Author: kayhayen Date: 2015-04-15.17:46:23
This is somewhat related to:

In Nuitka, currently, the global trace of a module variable does not include the uses in other 
modules. Accesses from there work merely as attribute read/writes, and so the overwriting of the 
module variable that would shadow the builtin is not noticed either.

The solution is very similar. Nuitka should use guards to detect such writes and factor a condition 
about these into things too. Every access of a global then should be a run through that too.

But currently, it's by design the way you found. In practice, very little code relies on writing 
the builtins that way.

The use of SSA is on the rise in Nuitka pre-releases. In the future, we might be able to consider 
if there are any writes to the value, outside of the owning module, therefore making a more 
reliable decision. But currently, these inter-module optimizations do not happen yet.
msg1172 (view) Author: thimo Date: 2015-04-15.16:08:41
Assumed I have the following package (Py2):

from . import mymodule
mymodule.str = unicode = unicode

def func():
    print str
    print foo

The expected output is:
<type 'unicode'>
<type 'unicode'>

But after compilation I get:
<type 'str'>
<type 'unicode'>

Is that by design or is it a bug?
Date User Action Args
2015-04-15 17:46:23kayhayensetstatus: unread -> chatting
messages: + msg1175
title: order of namespace lookup, __builtins__ before module globals? -> Outside writes to builtiin names of a module are not taken into account
2015-04-15 16:08:41thimocreate