New submission from Trey Hunner <trey@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue45897>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to