Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Implement Path.__deepcopy__ avoiding infinite recursion#30198
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
fa7ed8b to68d25b3Comparejkseppan commentedJun 21, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I tried the same strategy with EDIT: this is actually easier to fix by just doing the shallow copy without |
8258353 to8fbb889Comparejkseppan commentedJun 23, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I changed this to remove the metaclass and implement the |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
8fbb889 toaa94ddaCompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
lib/matplotlib/path.py Outdated
| ifmemoisNone: | ||
| memo= {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is not needed,memo is always a dict.
The default value formemo is also not needed. Thememo argument is always passed to__deepcopy__().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes, when called viacopy.deepcopy, but this__deepcopy__ method is also aliased todeepcopy (just below the GitHub patch context) that is part of the public API of this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
we could change our deepcopy to callcopy.deepcopy internally (which might bet better?)
2d93b8e toa76ab5aCompareTo deep copy an object without calling deepcopy on the object itself,create a new object of the correct class and iterate calling deepcopy onits __dict__.Closesmatplotlib#29157 without relying on private CPython methods.Does not fix the other issue with TransformNode.__copy__.Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
without calling copy.copy
db1a305 to5c7c915Compare
QuLogic left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I tried this out on Fedora Rawhide with Python 3.14, and it worked.
d05b43d intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
tacaswell commentedJun 26, 2025
Thank you@jkseppan ! This is a better solution than my "reach up and touch private methods" version. |
…198-on-v3.10.xBackport PR#30198 on branch v3.10.x (Implement Path.__deepcopy__ avoiding infinite recursion)
Uh oh!
There was an error while loading.Please reload this page.
Implement
Path.__deepcopy__avoiding infinite recursionTo deep copy an object without calling deepcopy on the object itself, create a new object of the correct class and iterate calling deepcopy on its
__dict__.Closes#29157 without relying on private CPython methods.
In a separate commit, fix the other issue with
TransformNode.__copy__.PR summary
PR checklist