-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-115911: Ignore PermissionError during import from cwd #116131
base: main
Are you sure you want to change the base?
Conversation
8b1cbd4
to
ff4dfda
Compare
c026bb9
to
10ebce0
Compare
The new test fails (as intended) without the accompanying fix. Local test run on macOS 14.3.1
|
c48c021
to
f06124d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but I'd like to see another review from someone more familiar with importlib internals.
076a29d
to
b79fd8d
Compare
b79fd8d
to
64ac361
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one of the decorators you're adding might not be necessary, or at least can be simplified. Otherwise LGTM!
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
b6f0f65
to
be73efd
Compare
I have made the requested changes; please review again |
Thanks for making the requested changes! @brettcannon: please review the changes made to this pull request. |
f4d5e67
to
03f2dd6
Compare
On macOS `getcwd(3)` can return EACCES if a path component isn't readable, resulting in PermissionError. `PathFinder.find_spec()` now catches these and ignores them - the same treatment as a missing/deleted cwd. Introduces `test.support.os_helper.save_mode(path, ...)`, a context manager that restores the mode of a path on exit. This is allows finer control of exception handling and robust environment restoration across platforms in `FinderTests.test_permission_error_cwd()`. Co-authored-by: Jason R. Coombs <jaraco@jaraco.com> Co-authored-by: Brett Cannon <brett@python.org>
On macOS
getcwd(3)
can return EACCES if a path component isn't readable, resulting in PermissionError.PathFinder.find_spec()
now catches these and ignores them - the same treatment as a missing/deleted cwd.Introduces
test.support.os_helper.save_mode(path, ...)
, a context manager that restores the mode of a path on exit.This is allows finer control of exception handling and robust environment restoration across platforms in
FinderTests.test_permission_error_cwd()
.Fixes #115911
📚 Documentation preview 📚: https://cpython-previews--116131.org.readthedocs.build/