Repository navigation
Annotated assignment in a match block does not generate SETUP_ANNOTATIONS #105164
Copy link
Copy link
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on May 31, 2023 FWIW, it's a runtime error when the module is imported, not run as main:
$ cat lib.py match 0: case 0: x: int = 1 $ cat main.py import lib $ python main.py Traceback (most recent call last): File "main.py", line 1, in <module> import lib File "lib.py", line 3, in <module> x: int = 1 NameError: name '__annotations__' is not defined
I think
find_annincompile.cneeds to be taught aboutMatch_kind.Looks like @JelleZijlstra picked this up already. Feel free to ping me for review!
Reacted by Jelle Zijlstra and sunmy2019- added3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
on May 31, 2023 - changed the title
[-]annotated assignment in a match block does not generate SETUP_ANNOTATIONS[/-][+]Annotated assignment in a `match` block does not generate `SETUP_ANNOTATIONS`[/+]on May 31, 2023 - added 3 commits that reference this issue
on Jun 5, 2023 Thanks, looks like this is fixed
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
Compiling the following code:
generates
There is no
SETUP_ANNOTATIONSopcode generated despite the__annotations__access later on. (Found via google/pytype#1435 - for some reason this does not generate a runtime error, but it does cause issues for tools like pytype.)Your environment
cpython 3.10
Linked PRs