summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-08-16 18:20:15 (GMT)
committerGitHub <noreply@github.com>2022-08-16 18:20:15 (GMT)
commit48174fa0b949d6b1d0c1f074e7d4e47793759a43 (patch)
tree0a226307f02413be0a6378aaf58a378004b5a3fb /Modules
parentf215d7cac9a6f9b51ba864e4252686dee4e45d64 (diff)
downloadcpython-48174fa0b949d6b1d0c1f074e7d4e47793759a43.zip
cpython-48174fa0b949d6b1d0c1f074e7d4e47793759a43.tar.gz
cpython-48174fa0b949d6b1d0c1f074e7d4e47793759a43.tar.bz2
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`.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/errnomodule.c4
-rw-r--r--Modules/getpath.py6
2 files changed, 7 insertions, 3 deletions
diff --git a/Modules/errnomodule.c b/Modules/errnomodule.c
index 0516e73..4de4144 100644
--- a/Modules/errnomodule.c
+++ b/Modules/errnomodule.c
@@ -927,6 +927,10 @@ errno_exec(PyObject *module)
#ifdef EQFULL
add_errcode("EQFULL", EQFULL, "Interface output queue is full");
#endif
+#ifdef ENOTCAPABLE
+ // WASI extension
+ add_errcode("ENOTCAPABLE", ENOTCAPABLE, "Capabilities insufficient");
+#endif
Py_DECREF(error_dict);
return 0;
diff --git a/Modules/getpath.py b/Modules/getpath.py
index a50313a..e3558bc 100644
--- a/Modules/getpath.py
+++ b/Modules/getpath.py
@@ -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':