Message28729
Python 2.5 compiles the following piece of code
differently than Python 2.4:
g = 1
def f():
g += 1
In Python 2.4, this raises an UnboundLocalError. In
current svn trunk, it will increment the global g by 1.
(dis.dis shows that it actually compiles into
LOAD/STORE_GLOBAL opcodes.) It seems the compiler
doesn't treat augmented assignment as assignment for
the purpose of determining locals, as this still fails
correctly:
g = 1
def f():
g += 1
g = 5
I can't find where this optimization happens nowadays,
but it feels like a short fix.
|
|
Date |
User |
Action |
Args |
2007-08-23 14:40:26 | admin | link | issue1501934 messages |
2007-08-23 14:40:26 | admin | create | |
|