Skip to content

Commit e63e631

Browse files
authored
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.
1 parent 48a6255 commit e63e631

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-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

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,7 @@ TESTSUBDIRS= ctypes/test \
15161516
test/test_importlib/namespace_pkgs/project3/parent/child \
15171517
test/test_importlib/namespacedata01 \
15181518
test/test_importlib/partial \
1519+
test/test_importlib/resources \
15191520
test/test_importlib/source \
15201521
test/test_importlib/zipdata01 \
15211522
test/test_importlib/zipdata02 \

0 commit comments

Comments
 (0)