[Python-checkins] gh-100585: Fixed a bug where importlib.resources.as_file was leaving file pointers open (GH-100586)
jaraco
webhook-mailer at python.org
Wed Dec 28 16:31:49 EST 2022
https://github.com/python/cpython/commit/f10f503b24a35a43910a632ee50c7568bedd6664
commit: f10f503b24a35a43910a632ee50c7568bedd6664
branch: main
author: Samet YASLAN <sametyaslan at gmail.com>
committer: jaraco <jaraco at jaraco.com>
date: 2022-12-28T16:31:43-05:00
summary:
gh-100585: Fixed a bug where importlib.resources.as_file was leaving file pointers open (GH-100586)
* gh-100585: Fixed open fp bug in the imporlib module
* Added news for gh-100585
files:
A Misc/NEWS.d/next/Library/2022-12-28-17-38-39.gh-issue-100585.BiiTlG.rst
M Lib/importlib/resources/_common.py
diff --git a/Lib/importlib/resources/_common.py b/Lib/importlib/resources/_common.py
index 8c0be7ee547e..92a37e2c12b8 100644
--- a/Lib/importlib/resources/_common.py
+++ b/Lib/importlib/resources/_common.py
@@ -155,5 +155,5 @@ def _write_contents(target, source):
for item in source.iterdir():
_write_contents(child, item)
else:
- child.open('wb').write(source.read_bytes())
+ child.write_bytes(source.read_bytes())
return child
diff --git a/Misc/NEWS.d/next/Library/2022-12-28-17-38-39.gh-issue-100585.BiiTlG.rst b/Misc/NEWS.d/next/Library/2022-12-28-17-38-39.gh-issue-100585.BiiTlG.rst
new file mode 100644
index 000000000000..0bf33b8bdd02
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-12-28-17-38-39.gh-issue-100585.BiiTlG.rst
@@ -0,0 +1 @@
+Fixed a bug where importlib.resources.as_file was leaving file pointers open
More information about the Python-checkins
mailing list