-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Remove reference cycle when writing tarfiles #115256
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
CC: @encukou |
How can we know that no one is using this member? @furkanonder Do you have a particular question? I'm not sure why you mentioned me here. |
When and why this field was added? How it was used in earlier versions? When and why the comment was added? |
It was not used even when it was introduced. Several other classes at the time also define Line 1792 in d8faa36
The comment was added by @vadmium 8 years ago when he extended some of the docstrings. f817a48 The only public git repo I can find that accesses It appears that this is not just about lingering handles but may actually corrupt archives as reported here: #78843 |
I don't remember why I added the comment. I was probably studying how the module used TarInfo objects, and noticed it setting the tarfile attribute without any documentation or usage of that attribute. The attribute itself seems comes from implementing Pax format (c64e402). |
I've seen you fixing issues with the tarfile module. I tagged you in case you might have an idea about the issue raised here. Sorry if I've disturbed you. |
Triage: looks like this can be closed, please re-open if there more to do. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Proposal:
The following code keeps a file handle for eternity and even
gc.collect
does not help.The culprit is a line that itself says that it is not needed. Indeed, it is never used anywhere. https://github.com/python/cpython/blob/main/Lib/tarfile.py#L2033
Now the example might be a rather bad style, but even a typical use case where a TarFile variable is defined and closed afterwards will also keep some stuff in memory until
gc.collect
happens due to this line. Removing the line also adds a ResourceWarning to the bad style example which currently does not appear.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: