[New-bugs-announce] [issue45897] Frozen dataclasses with slots raise TypeError
Trey Hunner
report at bugs.python.org
Wed Nov 24 20:53:51 EST 2021
New submission from Trey Hunner <trey at truthful.technology>:
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
----------
messages: 406973
nosy: trey
priority: normal
severity: normal
status: open
title: Frozen dataclasses with slots raise TypeError
type: behavior
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45897>
_______________________________________
More information about the New-bugs-announce
mailing list