Skip to content

Commit

Permalink
add from __future__ import nested_scopes to strings passed to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyhylton committed Feb 27, 2001
1 parent bd00cda commit 5941d19
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Lib/test/test_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,24 @@ def fact(n):

print "11. unoptimized namespaces"

check_syntax("""def unoptimized_clash1(strip):
check_syntax("""from __future__ import nested_scopes
def unoptimized_clash1(strip):
def f(s):
from string import *
return strip(s) # ambiguity: free or local
return f
""")

check_syntax("""def unoptimized_clash2():
check_syntax("""from __future__ import nested_scopes
def unoptimized_clash2():
from string import *
def f(s):
return strip(s) # ambiguity: global or local
return f
""")

check_syntax("""def unoptimized_clash2():
check_syntax("""from __future__ import nested_scopes
def unoptimized_clash2():
from string import *
def g():
def f(s):
Expand All @@ -202,20 +205,23 @@ def f(s):
""")

# XXX could allow this for exec with const argument, but what's the point
check_syntax("""def error(y):
check_syntax("""from __future__ import nested_scopes
def error(y):
exec "a = 1"
def f(x):
return x + y
return f
""")

check_syntax("""def f(x):
check_syntax("""from __future__ import nested_scopes
def f(x):
def g():
return x
del x # can't del name
""")

check_syntax("""def f():
check_syntax("""from __future__ import nested_scopes
def f():
def g():
from string import *
return strip # global or local?
Expand Down

0 comments on commit 5941d19

Please sign in to comment.