Skip to content

Bug in 3.14.1 Release: Dataclass triggers exception when init=False and slots=True #142251

Closed as duplicate

Description

@mkrd

Bug report

Bug description:

Reproducible with:

from dataclasses import dataclass

@dataclass(init=False, slots=True)
class SomeClass:
	test: int

Stack trace:

Traceback (most recent call last):
  File ".../reproduce_issue.py", line 4, in <module>
    @dataclass(init=False, slots=True)
     ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.14/3.14.1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/dataclasses.py", line 1426, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
                          frozen, match_args, kw_only, slots,
                          weakref_slot)
  File "/opt/homebrew/Cellar/python@3.14/3.14.1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/dataclasses.py", line 1234, in _process_class
    cls = _add_slots(cls, frozen, weakref_slot, fields)
  File "/opt/homebrew/Cellar/python@3.14/3.14.1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/dataclasses.py", line 1401, in _add_slots
    init_annotate = newcls.__init__.__annotate__
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'wrapper_descriptor' object has no attribute '__annotate__'. Did you mean: '__getstate__'?

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Dec 4, 2025
  2. changed the title [-]Bug in 3.14.1 Release: Dataclass triggers exception[/-] [+]Bug in 3.14.1 Release: Dataclass triggers exception when init=False and slots=True[/+] on Dec 4, 2025
  3. StanFromIreland commented on Dec 4, 2025

    @StanFromIreland
    Member

    This seems to be a very recent regression, not present in 3.14.0 or 3.13.9.

  4. mkrd commented on Dec 4, 2025

    @mkrd
    Author

    Yes, I know that it works on 3.14.0. Not really sure, but it might have been introduced in #137530

  5. cmaloney commented on Dec 4, 2025

    @cmaloney
    Contributor

    I think this is a duplicate of gh-142214

  6. hugovk commented on Dec 4, 2025

    @hugovk
    Member

    Bisects to 12837c6 / #137711.

  7. hugovk commented on Dec 4, 2025

    @hugovk
    Member

    And the fix #142223 for #142214 fixes this.

    Thanks for the report, let's mark as a duplicate.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-dataclassestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions