From 0a2dc2bc16c42001c25613f28eb7eee78f790d51 Mon Sep 17 00:00:00 2001 From: Samet Yaslan Date: Wed, 28 Dec 2022 17:21:38 +0100 Subject: [PATCH 1/2] gh-100585: Fixed open fp bug in the imporlib module --- Lib/importlib/resources/_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/importlib/resources/_common.py b/Lib/importlib/resources/_common.py index 8c0be7ee547e01..92a37e2c12b8d9 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 From 938692fafd40c36190876a183388048066df08d3 Mon Sep 17 00:00:00 2001 From: Samet Yaslan Date: Wed, 28 Dec 2022 17:41:30 +0100 Subject: [PATCH 2/2] Added news for gh-100585 --- .../next/Library/2022-12-28-17-38-39.gh-issue-100585.BiiTlG.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2022-12-28-17-38-39.gh-issue-100585.BiiTlG.rst 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 00000000000000..0bf33b8bdd027d --- /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