Bug report
importlib.resources.as_file is leaving temporary file pointers open after writing their contents
see _write_contents function in importlib/resources/_common.py
Easy to repeat, just run the test case below with -We
Lib.test.test_importlib.resources.test_resource.ResourceFromZipsTest01.test_as_file_directory
Your environment
- CPython versions tested on: Python 3.12.0a3+
- Operating system and architecture: Ubuntu 22.04.1 LTS
I think it just needs to use Path.write_bytes and keep the file pointer closed.
Linked PRs
Bug report
importlib.resources.as_file is leaving temporary file pointers open after writing their contents
see
_write_contentsfunction in importlib/resources/_common.pyEasy to repeat, just run the test case below with
-WeLib.test.test_importlib.resources.test_resource.ResourceFromZipsTest01.test_as_file_directoryYour environment
I think it just needs to use
Path.write_bytesand keep the file pointer closed.Linked PRs