Skip to content

Commit

Permalink
bpo-44771: Sync with importlib_resources 5.2.2, fixing refleak. (pyth…
Browse files Browse the repository at this point in the history
…on#27497)

* bpo-44771: Sync with importlib_resources 5.2.2, fixing refleak.

* Include new 'resources' dir in the Makefile.
  • Loading branch information
jaraco authored Jul 31, 2021
1 parent 48a6255 commit e63e631
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Lib/importlib/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit e63e631

Please sign in to comment.