summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-07-31 00:37:09 (GMT)
committerGitHub <noreply@github.com>2021-07-31 00:37:09 (GMT)
commite63e6311aa258a5f3f49a7aed9fdde445fd384d6 (patch)
tree4d56c5537d9821e093e30f8bde4054e2232de08e /Lib/importlib
parent48a62559dfaf775e4f1cc56b19379c799e8e2587 (diff)
downloadcpython-e63e6311aa258a5f3f49a7aed9fdde445fd384d6.zip
cpython-e63e6311aa258a5f3f49a7aed9fdde445fd384d6.tar.gz
cpython-e63e6311aa258a5f3f49a7aed9fdde445fd384d6.tar.bz2
bpo-44771: Sync with importlib_resources 5.2.2, fixing refleak. (#27497)
* bpo-44771: Sync with importlib_resources 5.2.2, fixing refleak. * Include new 'resources' dir in the Makefile.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_common.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/importlib/_common.py b/Lib/importlib/_common.py
index 74654b3..9b126f3 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