-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-115911: Ignore PermissionError during import from cwd #116131
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
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.
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>
Failure |
@brettcannon I believe I've made the changes you requested. Please could you take another look? |
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.
Given that you address Brett's changes, I'm inclined to push this forward. We can revisit (and revert) if necessary.
Concerns were addressed. Let's proceed.
|
I think the buildbot failure is a flaky test, atleast on that runner. Of the 5 previous builds 3 failed on this test (3138, 3139, 3140) have failed in the same test, 2 succeeded (3142, 3143). Trying to reproduce the failure locally I saw it with the revision from this PR (a8dc6d6), but not previous revision in main (914c232). |
A second local run with rev a8dc6d6 has succeeded
|
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/