add from __future__ import nested_scopes to strings passed to compile

This commit is contained in:
Jeremy Hylton 2001-02-27 20:23:58 +00:00
parent bd00cdaf73
commit 5941d191de
1 changed files with 12 additions and 6 deletions

View File

@ -179,21 +179,24 @@ verify(f(6) == 720)
print "11. unoptimized namespaces" print "11. unoptimized namespaces"
check_syntax("""def unoptimized_clash1(strip): check_syntax("""from __future__ import nested_scopes
def unoptimized_clash1(strip):
def f(s): def f(s):
from string import * from string import *
return strip(s) # ambiguity: free or local return strip(s) # ambiguity: free or local
return f return f
""") """)
check_syntax("""def unoptimized_clash2(): check_syntax("""from __future__ import nested_scopes
def unoptimized_clash2():
from string import * from string import *
def f(s): def f(s):
return strip(s) # ambiguity: global or local return strip(s) # ambiguity: global or local
return f return f
""") """)
check_syntax("""def unoptimized_clash2(): check_syntax("""from __future__ import nested_scopes
def unoptimized_clash2():
from string import * from string import *
def g(): def g():
def f(s): def f(s):
@ -202,20 +205,23 @@ check_syntax("""def unoptimized_clash2():
""") """)
# XXX could allow this for exec with const argument, but what's the point # 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" exec "a = 1"
def f(x): def f(x):
return x + y return x + y
return f return f
""") """)
check_syntax("""def f(x): check_syntax("""from __future__ import nested_scopes
def f(x):
def g(): def g():
return x return x
del x # can't del name del x # can't del name
""") """)
check_syntax("""def f(): check_syntax("""from __future__ import nested_scopes
def f():
def g(): def g():
from string import * from string import *
return strip # global or local? return strip # global or local?