Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 047e2c9

Browse files
committed
add test for SyntaxError on
def f(a): global a
1 parent c862cf4 commit 047e2c9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Lib/test/test_compile.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from test_support import verbose, TestFailed
22

33
if verbose:
4-
print 'Running test on duplicate arguments'
4+
print 'Running tests on argument handling'
55

66
try:
77
exec('def f(a, a): pass')
@@ -14,3 +14,9 @@
1414
raise TestFailed, "duplicate keyword arguments"
1515
except SyntaxError:
1616
pass
17+
18+
try:
19+
exec('def f(a): global a; a = 1')
20+
raise TestFailed, "variable is global and local"
21+
except SyntaxError:
22+
pass

0 commit comments

Comments
 (0)