From a4b3ef808e88981efd32a7d7eb7de5288329651a Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Tue, 1 Nov 2022 11:15:12 +0530 Subject: [PATCH 1/2] Fix ResourceWarning due to unclosed file resource. --- importlib_resources/_common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/importlib_resources/_common.py b/importlib_resources/_common.py index 9f19784..6a338c6 100644 --- a/importlib_resources/_common.py +++ b/importlib_resources/_common.py @@ -203,5 +203,6 @@ def _write_contents(target, source): for item in source.iterdir(): _write_contents(child, item) else: - child.open('wb').write(source.read_bytes()) + with child.open('wb') as fp: + fp.write(source.read_bytes()) return child From 45edbc1a5c7b1924042a1eea114da541a5d16d07 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 6 Dec 2022 08:52:54 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 7e0225f..f986136 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,8 @@ +v5.10.1 +======= + +* #274: Fixed ``ResourceWarning`` in ``_common``. + v5.10.0 =======