-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
global declaration in except has incorrect prior use #111123
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
Bug description:
I think the
global ahas no prior use in this code (and pyright tells me the same). But I don't understand why cpython thinks it has a prior use.output (Python 3.12.0):
the following code has no syntax error:
I can also reproduce this issue in 3.7.
I also don't know what the exact semantic of global/nonlocal inside statements like if/while/try/... is. I would like to know more about it because I'm currently writing pysource-codegen where I generate such cases.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs