- 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`.
Interface output queue is full
.. versionadded:: 3.11
+
+.. data:: ENOTCAPABLE
+
+ Capabilities insufficient. This error is mapped to the exception
+ :exc:`PermissionError`.
+
+ .. availability:: WASI, FreeBSD
+
+ .. versionadded:: 3.11.1
Raised when trying to run an operation without the adequate access
rights - for example filesystem permissions.
- Corresponds to :c:data:`errno` :py:data:`~errno.EACCES` and :py:data:`~errno.EPERM`.
+ Corresponds to :c:data:`errno` :py:data:`~errno.EACCES`,
+ :py:data:`~errno.EPERM`, and :py:data:`~errno.ENOTCAPABLE`.
+
+ .. versionchanged:: 3.11.1
+ WASI's :py:data:`~errno.ENOTCAPABLE` is now mapped to
+ :exc:`PermissionError`.
.. exception:: ProcessLookupError
+-- InterruptedError EINTR
+-- IsADirectoryError EISDIR
+-- NotADirectoryError ENOTDIR
- +-- PermissionError EACCES, EPERM
+ +-- PermissionError EACCES, EPERM, ENOTCAPABLE
+-- ProcessLookupError ESRCH
+-- TimeoutError ETIMEDOUT
"""
continue
excname, _, errnames = line.partition(' ')
for errname in filter(None, errnames.strip().split(', ')):
+ if errname == "ENOTCAPABLE" and not hasattr(errno, errname):
+ continue
_map[getattr(errno, errname)] = getattr(builtins, excname)
return _map
_map = _make_map(_pep_map)
othercodes = set(errno.errorcode) - set(self._map)
for errcode in othercodes:
e = OSError(errcode, "Some message")
- self.assertIs(type(e), OSError)
+ self.assertIs(type(e), OSError, repr(e))
def test_try_except(self):
filename = "some_hopefully_non_existing_file"
--- /dev/null
+On WASI :data:`~errno.ENOTCAPABLE` is now mapped to :exc:`PermissionError`.
+The :mod:`errno` modules exposes the new error number. ``getpath.py`` now
+ignores :exc:`PermissionError` when it cannot open landmark files
+``pybuilddir.txt`` and ``pyenv.cfg``.
#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;
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 = []
# 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':
ADD_ERRNO(InterruptedError, EINTR);
ADD_ERRNO(PermissionError, EACCES);
ADD_ERRNO(PermissionError, EPERM);
+#ifdef ENOTCAPABLE
+ // Extension for WASI capability-based security. Process lacks
+ // capability to access a resource.
+ ADD_ERRNO(PermissionError, ENOTCAPABLE);
+#endif
ADD_ERRNO(ProcessLookupError, ESRCH);
ADD_ERRNO(TimeoutError, ETIMEDOUT);