We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1b141f3 commit 6f50e4aCopy full SHA for 6f50e4a
tests/snippets/global_nonlocal.py
@@ -27,6 +27,14 @@ def y():
27
res = x()
28
assert res == 3, str(res)
29
30
+def x():
31
+ global a
32
+ global a # a here shouldn't generate SyntaxError
33
+ a = 3
34
+
35
+x()
36
+assert a == 3
37
38
# Invalid syntax:
39
src = """
40
b = 2
@@ -44,7 +52,6 @@ def y():
44
52
with assert_raises(SyntaxError):
45
53
exec(src)
46
54
47
-
48
55
49
56
50
57
def f():
@@ -62,6 +69,15 @@ def a():
62
69
nonlocal a
63
70
"""
64
71
72
+with assert_raises(SyntaxError):
73
+ exec(src)
74
75
+src = """
76
+def f():
77
+ print(a)
78
79
+"""
80
65
81
66
82
67
83
0 commit comments