[issue5578] unqualified exec in class body
"Martin v. Löwis" <report@bugs.python.org> at psf.upfronthosting.co.za
"Martin v. Löwis" <report@bugs.python.org> at psf.upfronthosting.co.za
Wed Apr 1 06:15:23 CEST 2009
Martin v. Löwis <martin at v.loewis.de> added the comment:
Reopening. The following piece of code changed it behavior between 2.5
and 2.6:
def f():
a = 2
class C:
exec 'a = 42'
abc = a
return C
print f().abc
In 2.6, this returns 2, because static analysis determines that the read
of 'a' comes from f's closure, yet the exec gets a new set of locals for
the body of C where it stores into.
This is highly counter-intuitive. For functions, the issue is resolved
by banning exec; the same should (now) happen for classes.
----------
nosy: +loewis
status: closed -> open
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5578>
_______________________________________
More information about the Python-bugs-list
mailing list