From 0e36363d13a8990e547bbf259719b618e2ec158b Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 16 Aug 2022 21:57:17 +0200 Subject: [PATCH] gh-96005: FreeBSD has ENOTCAPABLE, too --- Doc/library/errno.rst | 2 +- Lib/test/test_exception_hierarchy.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/errno.rst b/Doc/library/errno.rst index da4e964ac3f0c9..5122c69697ef91 100644 --- a/Doc/library/errno.rst +++ b/Doc/library/errno.rst @@ -663,6 +663,6 @@ defined by the module. The specific list of defined symbols is available as Capabilities insufficient. This error is mapped to the exception :exc:`PermissionError`. - .. availability:: WASI + .. availability:: WASI, FreeBSD .. versionadded:: 3.11.1 diff --git a/Lib/test/test_exception_hierarchy.py b/Lib/test/test_exception_hierarchy.py index 89fe9ddcefba3e..3318fa8e7746f7 100644 --- a/Lib/test/test_exception_hierarchy.py +++ b/Lib/test/test_exception_hierarchy.py @@ -63,7 +63,7 @@ def test_select_error(self): +-- InterruptedError EINTR +-- IsADirectoryError EISDIR +-- NotADirectoryError ENOTDIR - +-- PermissionError EACCES, EPERM + +-- PermissionError EACCES, EPERM, ENOTCAPABLE +-- ProcessLookupError ESRCH +-- TimeoutError ETIMEDOUT """ @@ -75,6 +75,8 @@ def _make_map(s): 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) @@ -91,7 +93,7 @@ def test_errno_mapping(self): 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"