-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Python 3.13 regression: Recursive dataclasses fail to ==: RecursionError: maximum recursion depth exceeded #116647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I believe lists are documented as checking for identity. In any case, I believe this is the equivalent for lists (in main).
|
I can confirm that reverting 18cfc1e on main makes the comparison return True. |
Is relying on that a good idea? Probably still crashes for mutual recursion, just like with lists? a = []
b = [a]
a.append(b)
a == b |
I merged the attached PR, because it restores the previous behavior for recursive children, and it generally makes sense to short-circuit dataclass equality to True when comparing a dataclass instance to itself. There could still be backwards-incompatibilities resulting from 18cfc1e. All it would require is a custom user class (not a dataclass) that implements (The other form that could cause a backward incompatibility would be a class that can return |
Bug report
Bug description:
There is a regression in comparing recursive dataclasses for equality in Python 3.13.0 from the first alpha until at least a4.
Python 3.12
Python 3.13
This has started happening since 18cfc1e.
Previously, tuples were compared via
==
, which skips calling__eq__
for items with the same identity. Now it skips the identity check and compares items directly with__eq__
, causingRecursionError
.This breaks sip-build; hence, we cannot build pyqt5 or pyqt6 in Fedora with Python 3.13 to test the entire stack. For details, see this Fedora bugzilla.
cc @rhettinger @ericvsmith
Thanks to @swt2c for bisecting the problem. Thanks to @encukou who gave me a hint of what to look for when finding the smaller reproducer.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: