Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing a file returned by
AbstractFileSystem.open(..., compression=...)can leave the underlying filesystem file open. For codecs such as gzip, bz2 and lzma, closing the compression stream does not close a caller-provided file. This delays resource release and can defer a write/upload error until garbage collection.Keep ownership of both streams in a private wrapper. Close the compression stream first to finish its trailer, then close the underlying file in
finally. Preserve the unwrapped object when compression inference selects no codec, and keep transaction queues pointing to the raw file.The returned object retains the file-like interface but is a wrapper, so its concrete type is no longer the codec class. This avoids replacing methods on codec objects, including C extension streams that do not allow setting
close.Fixes #1672.
Validation on Python 3.12.13 / Windows:
master: 24 leave the raw file open and six fail to propagate its close error.test_glob_weird_characterscases that try to create a directory containing|, which Windows rejects withWinError 123; the same failures were reproduced on unmodifiedmaster.git diff --check, and a full Sphinx HTML build with-W --keep-goingpass. The optional full cloud/backend and downstream integration suites were not run locally.AI assistance: this patch and its regression tests were developed and validated with OpenAI Codex, including a separate code review. The test results above are from commands executed by Codex.