FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Avoid file descriptor refleaks in as_file. by jaraco · Pull Request #234 · python/importlib_resources · GitHub

Repository navigation

Avoid file descriptor refleaks in as_file. - #234

Merged
jaraco merged 2 commits into
mainfrom
bugfix/as_file-refleak
Jul 30, 2021
Merged

jaraco merged 2 commits into
mainfrom
bugfix/as_file-refleak

Conversation

jaraco commented Jul 30, 2021

Copy link
Copy Markdown
Member

As reported in python/cpython#27436 (comment), merging the latest importlib_resources into CPython revealed a refleak. It appears the refleak has long been a part of the implementation but was previously uncovered by the tests. This change fixes that refleak.

jaraco merged commit 64484b7 into main Jul 30, 2021
jaraco deleted the bugfix/as_file-refleak branch July 30, 2021 20:55
jaraco restored the bugfix/as_file-refleak branch July 30, 2021 20:55
jaraco deleted the bugfix/as_file-refleak branch July 30, 2021 20:55
try:
os.remove(raw_path)
except (FileNotFoundError, PermissionError):
except FileNotFoundError:

FFY00 Jul 31, 2021 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why this part though? IIRC it was added because for some reason Windows will set high permissions on temporary files sometimes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I believe this exception was masking the underlying issue that the file descriptor wasn't being closed. Windows won't allow deletion of files in use, so when we encountered the issue, we suppressed the exception, allowing the file descriptor to remain unclosed and on Windows leaving the file undeleted. Now that the file descriptor is unconditionally closed, there's no longer any need to suppress this exception and as you can see, tests still pass on Windows.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL