-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Captured exceptions are keeping user objects alive unnecessarily in the stdlib #81001
Comments
There are multiple places in the standard library where the code captures an exception and reraises it later (outside of the original except). This is known to cause a cycle as saving the exception has a traceback that eventually points back to the exception, but it is especially problematic as it keeps alive the objects that the user has as well. This can be reproduced with the following example:
There are places in the standard library that try to get around this. See acb9fa7 as an example. This change did not include the exception path though, when the This issue is to fix the instances found in socket.py, codeop.py and dyld.py. By either setting the variable to None to remove the name or if it needs to be reraised by using a finally to delete it. This is basically the same that a try except would do, which automagically adds a finally to delete the local name used in the Note that eventually those objects will just be collected by the gc, it is just an improvement. I'm preparing a PR for those three modules. |
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: