[issue45897] Frozen dataclasses with slots raise TypeError

2021-12-02 Thread Alex Waygood
Change by Alex Waygood : -- keywords: +patch pull_requests: +28119 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29895 ___ Python tracker ___

[issue45897] Frozen dataclasses with slots raise TypeError

2021-12-02 Thread Alex Waygood
Alex Waygood 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

[issue45897] Frozen dataclasses with slots raise TypeError

2021-11-25 Thread Eric V. Smith
Eric V. Smith added the comment: I think the error should be AttributeError, which is what you'd get if the class weren't frozen. -- ___ Python tracker ___

[issue45897] Frozen dataclasses with slots raise TypeError

2021-11-24 Thread Eric V. Smith
Change by Eric V. Smith : -- versions: +Python 3.11 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45897] Frozen dataclasses with slots raise TypeError

2021-11-24 Thread Eric V. Smith
Change by Eric V. Smith : -- assignee: -> eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45897] Frozen dataclasses with slots raise TypeError

2021-11-24 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45897] Frozen dataclasses with slots raise TypeError

2021-11-24 Thread Alex Waygood
Alex Waygood added the comment: This looks to be due to the fact that `slots=True` leads to the creation of an entirely new class (see line 1102), meaning that in the `super(cls, self)` calls in lines 611 and 618 (in the `_frozen_get_del_attr` function, responsible for generating

[issue45897] Frozen dataclasses with slots raise TypeError

2021-11-24 Thread Trey Hunner
New submission from Trey Hunner : 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