gh-115911: Ignore PermissionError during import from cwd#116131
gh-115911: Ignore PermissionError during import from cwd#116131jaraco merged 7 commits intopython:mainfrom
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
jaraco
left a comment
There was a problem hiding this comment.
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? |
jaraco
left a comment
There was a problem hiding this comment.
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/