>>> @dataclass
... classC:
... f: "C"
...
>>> c = C(None)
>>> c.f = c
>>> c
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 2, in __repr__
File "<string>", line 2, in __repr__
File "<string>", line 2, in __repr__
[Previous line repeated 328 more times]
RecursionError: maximum recursion depth exceeded
>>>
This seems like a difficult problem to tackle in all cases, if two dataclasses reference each other the cycle could be complex to identify and introduce complexity.
The way repr is defined is part of PEP-557 and actually force this behavior.
Should the repr parameter default to False or not include the repr of each field?
New changeset b9182aa by Eric V. Smith (Miss Islington (bot)) in branch '3.7': bpo-33947: dataclasses no longer can raise RecursionError in repr (GF9916) (bpo-9970) b9182aa
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: