summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-09-13 11:00:45 (GMT)
committerGitHub <noreply@github.com>2022-09-13 11:00:45 (GMT)
commitbc337a77666055283feeb3efbe17510dd038fb34 (patch)
tree2f9867cab326bd97dbbf6cdbc58306a4f23f1380 /Modules
parentc4cf745c723f19dbc5b304bfb21cf77ac9aa40b8 (diff)
downloadcpython-bc337a77666055283feeb3efbe17510dd038fb34.zip
cpython-bc337a77666055283feeb3efbe17510dd038fb34.tar.gz
cpython-bc337a77666055283feeb3efbe17510dd038fb34.tar.bz2
[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`.
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 dceeed7..e09fda9 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':