You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A class with __abstractmethods__ can be instantiated once its call is specialized to CALL_ALLOC_AND_ENTER_INIT #162600
interpreter-core(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error
For a plain class with a Python __init__ and a non-empty __abstractmethods__, the first evaluation of A() raises TypeError: Can't instantiate abstract class, and the later ones of the same call return instances:
On 3.12 every call raises. specialize_class_call (Python/specialize.c) picks CALL_ALLOC_AND_ENTER_INIT, which skips object_new and so its check of Py_TPFLAGS_IS_ABSTRACT; checking the flag there would keep the error. It needs __abstractmethods__ set by hand (classes with ABCMeta are not specialized this way), but the result of the same expression shouldn't change after a few calls. I found it while writing a Lean spec of Python.
Thank you for taking the time to open this issue. Python is a community-driven project, and we want it to be a welcoming place to learn and collaborate.
This issue appears to have been written with AI assistance. Please explain your issue in your own words and describe how you checked the information you provided. This helps us understand your issue and leaves more time to address other issues.
It needs __abstractmethods__ set by hand (classes with ABCMeta are not specialized this way), but the result of the same expression shouldn't change after a few calls.
I believe this is where we disagree. I don't think this is meant to be the case. Users are not meant to write this by hand unless they know what they are doing and thus I believe it's something that doesn't qualify as a real bug.
OTOH, if the fix does not reduce performance, we can accept it. However we definitely don't want to slow down others just because of singular cases. How much performance change are we having if we were to to fix this? (on a PGO+LTO build with say pydantic models and dataclasses, as well as regular simple classes).
interpreter-core(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error
Activity
bedevere-app commentedon Nov 25, 2026
Thank you for taking the time to open this issue. Python is a community-driven project, and we want it to be a welcoming place to learn and collaborate.
This issue appears to have been written with AI assistance. Please explain your issue in your own words and describe how you checked the information you provided. This helps us understand your issue and leaves more time to address other issues.
Please read our guidelines for using AI tools.
picnixz commentedon Nov 25, 2026
I believe this is where we disagree. I don't think this is meant to be the case. Users are not meant to write this by hand unless they know what they are doing and thus I believe it's something that doesn't qualify as a real bug.
OTOH, if the fix does not reduce performance, we can accept it. However we definitely don't want to slow down others just because of singular cases. How much performance change are we having if we were to to fix this? (on a PGO+LTO build with say pydantic models and dataclasses, as well as regular simple classes).