Message406973
When making a dataclass with slots=True and frozen=True, assigning to an invalid attribute raises a TypeError rather than a FrozenInstanceError:
>>> from dataclasses import dataclass
>>> @dataclass(frozen=True, slots=True)
... class Vector:
... x: float
... y: float
... z: float
...
>>> v = Vector(1, 2, 3)
>>> v.a = 4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 5, in __setattr__
TypeError: super(type, obj): obj must be an instance or subtype of type |
|
Date |
User |
Action |
Args |
2021-11-25 01:53:51 | trey | set | recipients:
+ trey |
2021-11-25 01:53:51 | trey | set | messageid: <1637805231.22.0.691568548115.issue45897@roundup.psfhosted.org> |
2021-11-25 01:53:51 | trey | link | issue45897 messages |
2021-11-25 01:53:51 | trey | create | |
|