Skip to content

Commit 108d5cf

Browse files
committed
bpo-44771: Sync with importlib_resources 5.2.2, fixing refleak.
1 parent 48a6255 commit 108d5cf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/importlib/_common.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ def _tempfile(reader, suffix=''):
8787
# properly.
8888
fd, raw_path = tempfile.mkstemp(suffix=suffix)
8989
try:
90-
os.write(fd, reader())
91-
os.close(fd)
90+
try:
91+
os.write(fd, reader())
92+
finally:
93+
os.close(fd)
9294
del reader
9395
yield pathlib.Path(raw_path)
9496
finally:
9597
try:
9698
os.remove(raw_path)
97-
except (FileNotFoundError, PermissionError):
99+
except FileNotFoundError:
98100
pass
99101

100102

0 commit comments

Comments
 (0)