Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dataclasses without__init__ no longer work in 3.14.1 due to #137711 #142214

Closed
Labels
3.14bugs and security fixes3.15new features, bugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directorytopic-dataclassestopic-typingtype-bugAn unexpected behavior, bug, or error
@emontnemery

Description

@emontnemery

Bug report

Bug description:

The resolution for#137530,#137711 which was backported to 3.14 and included in 3.14.1, breaks dataclasses without__init__.
Although a dataclass without__init__ doesn't seem that helpful, it doesn't seem to be explicitly forbidden and shouldn't break in a point release.

fromdataclassesimportdataclass,field@dataclass(slots=True,init=False)classMyClass:attr:intdef__new__(cls,attr:int)->Self:self.attr=attrreturnself

Error message:

$ python3 dataclasses_issue.pyTraceback (most recent call last):  File"/home/erik/dataclasses_issue.py", line3, in<module>@dataclass(slots=True,init=False)~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^  File"/home/erik/.pyenv/versions/3.14.1/lib/python3.14/dataclasses.py", line1426, inwrapreturn _process_class(cls, init,repr, eq, order, unsafe_hash,                          frozen, match_args, kw_only, slots,                          weakref_slot)  File"/home/erik/.pyenv/versions/3.14.1/lib/python3.14/dataclasses.py", line1234, in_process_classcls= _add_slots(cls, frozen, weakref_slot, fields)  File"/home/erik/.pyenv/versions/3.14.1/lib/python3.14/dataclasses.py", line1401, 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.1

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directorytopic-dataclassestopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp