[issue991196] An inconsistency with nested scopes

Mark Dickinson report at bugs.python.org
Wed May 26 13:40:11 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

> I'm guessing that somewhere in the python source there is some code that goes [...]

Unfortunately it's not nearly that simple.  As I mentioned in my message on python-dev, the problem is that 'y' gets bound with a 'STORE_NAME' opcode, which puts 'y' into the locals dict, and then retrieved from within the function with a 'LOAD_GLOBAL' opcode, which looks in the globals dict;  hence the NameError.

So should the compiler be generating a 'LOAD_NAME' instead of a 'LOAD_GLOBAL' for this code?  I'm not really familiar with the compilation process, so I've no idea whether this makes sense, or what impact it might have on existing code.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue991196>
_______________________________________


More information about the Python-bugs-list mailing list