[3.11] gh-96005: Handle WASI ENOTCAPABLE in getpath (GH-96006) (GH-96034) (GH-96038)

- 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-09-13 13:00:45 +02:00 committed by GitHub
parent c4cf745c72
commit bc337a7766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 6 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':