-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Abstract class inheritance regression in Python 3.13 #127967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is this related to #124520? |
Hello, @ZeroIntensity! Seems like it is related. I've read through the discussion at #124520 and modified the snippet according to the new requirements of metaclasses initialization, i.e. moved custom logic to the
Here's a modified snippet:
Unfortunately, this doesn't fix the problem when it's run with Python
|
You need to call
|
You're right. Adding In case someone stumbles upon this discussion in the future, here's a patch against original snippet which has fixed the erroneous behavior: --- a/test.py 2024-12-15 21:59:57.248825568 +0300
+++ b/test.py 2024-12-15 21:59:34.655857763 +0300
@@ -2,12 +2,13 @@
class EnumMetaclass(type(ctypes.c_uint)):
def __new__(metaclass, name, bases, cls_dict):
- cls = type(ctypes.c_uint).__new__(metaclass, name, bases, cls_dict)
- if name == 'Enum':
- return cls
- for i, value in enumerate(cls_dict['_values_']):
- setattr(cls, value, cls.from_param(i))
+ cls = super().__new__(metaclass, name, bases, cls_dict)
return cls
+ def __init__(self, name, bases, cls_dict):
+ super().__init__(name, bases, cls_dict)
+ if name != 'Enum':
+ for i, value in enumerate(cls_dict['_values_']):
+ setattr(self, value, self.from_param(i))
class Enum(ctypes.c_uint, metaclass=EnumMetaclass):
@classmethod @ZeroIntensity, thank you very much for your help and your fast replies! Best regards, Grigory |
Bug report
Bug description:
Good day to you, dear Python maintainers! I have a little issue with the recent Python release, 3.13. Here's a snippet:
When run with Python
3.12.7
, I get the following output:When run with Python
3.13.1
, I get the following output:As you can see, new TypeError detection triggers where it presumably mustn't have, because it's perfectly correct to call
from_param
fromNodeType
object.I checked that this problem persists in both
3.13.0
and3.13.1
.CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: