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

dataclass.__eq__ no longer errors on missing attributes in Python 3.13 #134488

Open
Labels
3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesstdlibPython modules in the Lib dirtopic-dataclassestype-bugAn unexpected behavior, bug, or error
@willhcr

Description

@willhcr

Bug report

Bug description:

Description

Equality with self now returns True in 3.13 for dataclasses with deleted attributes. Previously, this would raise an exception.

This may be related to changes discussed in#128294. However, unlike
other reports (#120645,#116647) where something that was True in 3.12 is now False or an Exception,
this issue is the inverse. In 3.13, the equality test silently returns True when previously it would raise.

This class is badly behaved, it should probably still raise an error.

Test Case

importdataclasses@dataclasses.dataclassclassTest:a:intdef__init__(self):self.a=1defdel_a(self):delself.ao1=Test()o2=Test()o1.del_a()o2.del_a()print(o1==o1)# True (3.13), raises AttributeError (3.12)print(o1==o2)# raises AttributeError (3.13, 3.12)# AttributeError: 'Test' object has no attribute 'a'

CPython versions tested on:

3.13, 3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesstdlibPython modules in the Lib dirtopic-dataclassestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp