gh-96005: Handle WASI ENOTCAPABLE in getpath (GH-96006)

- On WASI `ENOTCAPABLE` is now mapped to `PermissionError`.
- The `errno` modules exposes the new error number.
- `getpath.py` now ignores `PermissionError` when it cannot open landmark
  files `pybuilddir.txt` and `pyenv.cfg`.
This commit is contained in:
Christian Heimes 2022-08-16 20:20:15 +02:00 committed by GitHub
parent f215d7cac9
commit 48174fa0b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 4 deletions

View file

@ -351,11 +351,11 @@ if not home and not py_setpath:
try:
# Read pyvenv.cfg from one level above executable
pyvenvcfg = readlines(joinpath(venv_prefix, VENV_LANDMARK))
except FileNotFoundError:
except (FileNotFoundError, PermissionError):
# Try the same directory as executable
pyvenvcfg = readlines(joinpath(venv_prefix2, VENV_LANDMARK))
venv_prefix = venv_prefix2
except FileNotFoundError:
except (FileNotFoundError, PermissionError):
venv_prefix = None
pyvenvcfg = []
@ -475,7 +475,7 @@ if ((not home_was_set and real_executable_dir and not py_setpath)
# File exists but is empty
platstdlib_dir = real_executable_dir
build_prefix = joinpath(real_executable_dir, VPATH)
except FileNotFoundError:
except (FileNotFoundError, PermissionError):
if isfile(joinpath(real_executable_dir, BUILD_LANDMARK)):
build_prefix = joinpath(real_executable_dir, VPATH)
if os_name == 'nt':