diff options
| author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-10-21 12:38:29 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-21 12:38:29 (GMT) |
| commit | b578e51f026a45576930816d6784697192ed472e (patch) | |
| tree | 80c166fec30df2d8fcbbd17d00868d565aed1c38 /Lib/test/test_compile.py | |
| parent | f71cd5394efe154ba92228b2b67be910cc1ede95 (diff) | |
| download | cpython-b578e51f026a45576930816d6784697192ed472e.zip cpython-b578e51f026a45576930816d6784697192ed472e.tar.gz cpython-b578e51f026a45576930816d6784697192ed472e.tar.bz2 | |
gh-111123: symtable should visit exception handlers before the else block (#111142)
Diffstat (limited to 'Lib/test/test_compile.py')
| -rw-r--r-- | Lib/test/test_compile.py | 17 |
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 |
