]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44771: Sync with importlib_resources 5.2.2, fixing refleak. (#27497)
authorJason R. Coombs <jaraco@jaraco.com>
Sat, 31 Jul 2021 00:37:09 +0000 (20:37 -0400)
committerGitHub <noreply@github.com>
Sat, 31 Jul 2021 00:37:09 +0000 (20:37 -0400)
* bpo-44771: Sync with importlib_resources 5.2.2, fixing refleak.

* Include new 'resources' dir in the Makefile.

Lib/importlib/_common.py
Makefile.pre.in

index 74654b34ed5a9d8eabebad53434d282c215522ea..9b126f3174974c6e4625b5809276081f13cb77d0 100644 (file)
@@ -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
 
 
index bf023a084dc4782e33abf1796e365c25f6ea0183..f503ac4d876726890d0b1e45f84579f1cf4fdf63 100644 (file)
@@ -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 \