Skip to content

dataclass(a=nan) == dataclass(a=nan) change in truthnes between 3.12 and 3.13 #120645

Open
@hroncok

Description

@hroncok

Bug report

Bug description:

from dataclasses import dataclass
@dataclass
class a:
    a: float

nan = float('nan')

Python 3.12.3

>>> nan == nan
False
>>> a(nan) == a(nan)
True

Python 3.13.0b2

>>> nan == nan
False
>>> a(nan) == a(nan)
False

The new behavior kinda makes sense, but it is a behavior change nevertheless.

Was it intentional or accidental? I cannot find anything relevant in https://docs.python.org/3.13/whatsnew/3.13.html

Possibly related to #104904 but I have not yet bisected this.

This breaks expectations in the testsuite of cattrs: python-attrs/cattrs#547

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions