[issue45897] Frozen dataclasses with slots raise TypeError
Alex Waygood
report at bugs.python.org
Thu Dec 2 11:55:46 EST 2021
Alex Waygood <Alex.Waygood at Gmail.com> added the comment:
You get the same error if you subclass a frozen dataclass, then try to set an attribute that is not one of the superclass's __slots__:
```
>>> @dataclass(slots=True, frozen=True)
... class Point:
... x: int
... y: int
...
...
>>> class Subclass(Point): pass
...
>>> s = Subclass(1, 2)
>>> s.z = 5
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
s.z = 5
File "<string>", line 7, in __setattr__
TypeError: super(type, obj): obj must be an instance or subtype of type
```
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45897>
_______________________________________
More information about the Python-bugs-list
mailing list