-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-131492: gh-131461: handle exceptions in GzipFile constructor while owning resources #131462
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
gh-131492: gh-131461: handle exceptions in GzipFile constructor while owning resources #131462
Conversation
Misc/NEWS.d/next/Library/2025-03-19-14-36-54.gh-issue-131461.uDUmdY.rst
Outdated
Show resolved
Hide resolved
…DUmdY.rst Co-authored-by: Victor Stinner <vstinner@python.org>
@cmaloney: Would you mind to review this fix? |
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.
Would it be possible to write a test with such broken file object?
There's already a test in test_tarfile: test_open_nonwritable_fileobj the failure will be enforced by #128973 I added check_no_resource_warning to make the assert hold until then |
Co-authored-by: Victor Stinner <vstinner@python.org>
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.
LGTM
The CI fails:
|
Co-authored-by: Victor Stinner <vstinner@python.org>
🤦 |
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.
LGTM.
I would add support.gc_collect()
in tests.
Misc/NEWS.d/next/Library/2025-03-20-08-32-49.gh-issue-131492.saC2cA.rst
Outdated
Show resolved
Hide resolved
…aC2cA.rst Co-authored-by: Victor Stinner <vstinner@python.org>
…aC2cA.rst Co-authored-by: Victor Stinner <vstinner@python.org>
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.
LGTM
Thanks @graingert for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…ructor while owning resources (pythonGH-131462) (cherry picked from commit ce79274) Co-authored-by: Thomas Grainger <tagrain@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
GH-131518 is a backport of this pull request to the 3.13 branch. |
…ructor while owning resources (pythonGH-131462) (cherry picked from commit ce79274) Co-authored-by: Thomas Grainger <tagrain@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
GH-131519 is a backport of this pull request to the 3.12 branch. |
Hum, the backports mention ResourceWarning, whereas ResourceWarning only exists in Python 3.14. If we want to backport this change to 3.13 and 3.12, maybe references to ResourceWarning should be removed? What do you think @graingert? |
Oh yeah nix the 3.14 specific bits of the changelog from the backports |
I've removed the references to a ResourceWarning in the backports |
…ructor while owning resources (python#131462) Co-authored-by: Victor Stinner <vstinner@python.org>
Uh oh!
There was an error while loading. Please reload this page.