-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
RecursionError during copy.deepcopy of an ast-tree with parent references #120108
Comments
and I forgot to mention that it worked on 3.12. |
You can increase the recursion limit using |
The sample succeeds for me on main if I |
It looks like it depends on the with of the tree and not just the depth (because I would end up with deep, but a not so wide ast tree otherwise). |
Yes, I think when it tries to copy each I think this is related:
The problem is that the child fields are now in the args rather than the state, and I can't think of a way to fix this in |
Here's another fun fact: the
This is arguably a bug but I'm not sure what to do about it, other than to stop sharing the expr_context objects. |
I think you should definitely stop sharing the |
Yes, I figured this also out some time ago, and wrote some work around for it (to make the parent connection work). |
@serhiy-storchaka suggested in #118855 (comment) to make |
Making them immutable would break compatibility, unfortunately. In any case, that's off topic for this issue. I'm about to send a PR fixing this bug. |
…ributes (pythonGH-120114) (cherry picked from commit 42b2c9d) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…ributes (pythonGH-120114) (cherry picked from commit 42b2c9d) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Bug report
Bug description:
python 3.13 raises an
RecursionError
when I try todeepcopy
the ast in the following example.output (Python 3.13.0b1+):
The problem can be reproduced on the current main (5c02ea8)
I was able to bisect the problem down to ed4dfd8 (@JelleZijlstra may be you know more here)
The code in the example looks big but is already minimized.
I hope that this example is simple enough to find and fix the bug, I can try to find a smaller one if it is needed.
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: