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
Derived dataclass with slots generates exception calling super().__init__() #137237
The following code generates an exception where using a derived dataclass with slots. The expected behavior is for no exception to be raised for Derived3. The exception is: Exception: super(type, obj): obj (instance of Derived3) is not an instance or subtype of type (Derived3).
> python polymorphism.py
D1: <__main__.Derived1 object at 0x000001921C709160>
D2: Derived2(b21='s1', d21='s2')
Exception: super(type, obj): obj (instance of Derived3) is not an instance or subtype of type (Derived3).
PS: I am not sure why I get different string for the output of D1 and for D2, but I assume this is existing behavior (though weird).
Activity
StanFromIreland commentedon Jul 30, 2025
D2is a dataclass, which implements a nice__repr__for you.I am unable to reproduce on main, I presume this has been fixed.
tycarac commentedon Jul 30, 2025
Thanks for the quick response. I was testing with Python version 3.13.5
StanFromIreland commentedon Jul 30, 2025
Yes, this is now fixed and will be available in the next release.