Staging
v0.8.1
swh:1:snp:635f4099902912592851108bcac178ff574f7c5f
Revision 7889107be7cb5a28aabcdfa33778bdce3e9b5c27 authored by Jeremy Hylton on 01 March 2001, 06:09:34 UTC, committed by Jeremy Hylton on 01 March 2001, 06:09:34 UTC
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.
1 parent a52e8fe
History
Tip revision: 550e4673be538d98b6ddf5550b3922539cf5c4b2 authored by Victor Stinner on 08 December 2020, 23:32:54 UTC
bpo-32381: Add _PyRun_SimpleFileObject() (GH-23709)
Tip revision: 550e467
File Mode Size
Demo
Doc
Grammar
Include
Lib
Mac
Misc
Modules
Objects
PC
PCbuild
Parser
Python
Tools
.cvsignore -rw-r--r-- 79 bytes
.hgtags -rw-r--r-- 1.8 KB
LICENSE -rw-r--r-- 8.6 KB
Makefile.pre.in -rw-r--r-- 21.8 KB
README -rw-r--r-- 36.2 KB
acconfig.h -rw-r--r-- 6.1 KB
config.h.in -rw-r--r-- 16.5 KB
configure -rwxr-xr-x 176.9 KB
configure.in -rw-r--r-- 35.7 KB
install-sh -rwxr-xr-x 5.5 KB
setup.py -rw-r--r-- 25.2 KB

README

back to top