Skip to content

dataclasses: frozen dataclasses with slots' __setattr__ and __delattr__ does not work. #105936

Description

@avboag

Bug report

The check in frozen dataclasses' __setattr__ and __delattr__ does not work when slots=True:

@dataclass(frozen=True, slots=True)
class C:
    i: int

C(10).j = 5

crashes with

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

instead of raising a FrozenInstanceError.

Likewise,

@dataclass(frozen=True, slots=True)
class C:
    i: int

class D(C):
    pass

D(10).j = 5

crashes with the same error instead of working.

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Jun 20, 2023
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 26, 2023
  3. added a commit that references this issue on Apr 12, 2026
  4. added a commit that references this issue on Apr 12, 2026
  5. added 3 commits that reference this issue on Apr 12, 2026
  6. gpshead commented on Apr 13, 2026

    @gpshead
    Member

    A 3.13 is up as a Draft PR because it requires more changes and backporting pieces of some other stuff that is already in 3.14 in order for it to work.

  7. added a commit that references this issue on Apr 13, 2026
  8. added a commit that references this issue on Apr 25, 2026
  9. added a commit that references this issue on Apr 26, 2026
  10. self-assigned this
    on Apr 26, 2026
  11. gpshead commented on Apr 26, 2026

    @gpshead
    Member

    all merged. thanks for the report, contributions and reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions