summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r--Lib/test/test_compile.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index c4452e3..df6e5e4 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -1283,6 +1283,23 @@ class TestSpecifics(unittest.TestCase):
def f():
a if (1 if b else c) else d
+ def test_global_declaration_in_except_used_in_else(self):
+ # See gh-111123
+ code = textwrap.dedent("""\
+ def f():
+ try:
+ pass
+ %s Exception:
+ global a
+ else:
+ print(a)
+ """)
+
+ g, l = {'a': 5}, {}
+ for kw in ("except", "except*"):
+ exec(code % kw, g, l);
+
+
@requires_debug_ranges()
class TestSourcePositions(unittest.TestCase):
# Ensure that compiled code snippets have correct line and column numbers