From 108d5cf5e5dc6b56b63dc5e9f2f2836d831afa64 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 30 Jul 2021 16:58:04 -0400 Subject: [PATCH 1/2] bpo-44771: Sync with importlib_resources 5.2.2, fixing refleak. --- Lib/importlib/_common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Lib/importlib/_common.py b/Lib/importlib/_common.py index 74654b34ed5a9d..9b126f3174974c 100644 --- a/Lib/importlib/_common.py +++ b/Lib/importlib/_common.py @@ -87,14 +87,16 @@ def _tempfile(reader, suffix=''): # properly. fd, raw_path = tempfile.mkstemp(suffix=suffix) try: - os.write(fd, reader()) - os.close(fd) + try: + os.write(fd, reader()) + finally: + os.close(fd) del reader yield pathlib.Path(raw_path) finally: try: os.remove(raw_path) - except (FileNotFoundError, PermissionError): + except FileNotFoundError: pass From c0076d11e605f0a32516f604938d70b6dee50ad7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 30 Jul 2021 17:49:02 -0400 Subject: [PATCH 2/2] Include new 'resources' dir in the Makefile. --- Makefile.pre.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.pre.in b/Makefile.pre.in index bf023a084dc478..f503ac4d876726 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1516,6 +1516,7 @@ TESTSUBDIRS= ctypes/test \ test/test_importlib/namespace_pkgs/project3/parent/child \ test/test_importlib/namespacedata01 \ test/test_importlib/partial \ + test/test_importlib/resources \ test/test_importlib/source \ test/test_importlib/zipdata01 \ test/test_importlib/zipdata02 \