Mercurial > cpython-lru_cache-weakref
comparison Python/pythonmain.c @ 16892:f27d3299df39 legacy-trunk
Fix core dump in example from Samuele Pedroni:
from __future__ import nested_scopes
x=7
def f():
x=1
def g():
global x
def i():
def h():
return x
return h()
return i()
return g()
print f()
print x
This kind of code didn't work correctly because x was treated as free
in i, leading to an attempt to load x in g to make a closure for i.
Solution is to make global decl apply to nested scopes unless their is
an assignment. Thus, x in h is global.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Thu, 01 Mar 2001 06:09:34 +0000 |
| parents | 85140b354890 |
| children |
comparison
equal
deleted
inserted
replaced
| 16891:806c6ae23103 | 16892:f27d3299df39 |
|---|
