PEP 649: class __annotate__ is shadowed by compiler-generated one #133037
Labels
3.14
bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
topic-typing
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
I'm playing around with PEP 649, PEP 749 annotations and I found this surprising behaviour:
I'm not yet sure why I would write code with annotations and then also write an explicit
__annotate__
, but I would expect the explicit method to prevail over the compiler-generated one. If I explicitly setC.__annotate__ = some_func
afterwards it works as I would expect.Calling
dis
on the provided example shows both__annotate__
s getting compiled, and one overwriting the other in the class.Related to #119180.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: