gh-96005: FreeBSD has ENOTCAPABLE, too (GH-96034)

This commit is contained in:
Christian Heimes 2022-08-17 07:24:53 +02:00 committed by GitHub
parent f51f54f39d
commit da0aa518bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -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 Capabilities insufficient. This error is mapped to the exception
:exc:`PermissionError`. :exc:`PermissionError`.
.. availability:: WASI .. availability:: WASI, FreeBSD
.. versionadded:: 3.11.1 .. versionadded:: 3.11.1

View file

@ -63,7 +63,7 @@ class HierarchyTest(unittest.TestCase):
+-- InterruptedError EINTR +-- InterruptedError EINTR
+-- IsADirectoryError EISDIR +-- IsADirectoryError EISDIR
+-- NotADirectoryError ENOTDIR +-- NotADirectoryError ENOTDIR
+-- PermissionError EACCES, EPERM +-- PermissionError EACCES, EPERM, ENOTCAPABLE
+-- ProcessLookupError ESRCH +-- ProcessLookupError ESRCH
+-- TimeoutError ETIMEDOUT +-- TimeoutError ETIMEDOUT
""" """
@ -75,6 +75,8 @@ class HierarchyTest(unittest.TestCase):
continue continue
excname, _, errnames = line.partition(' ') excname, _, errnames = line.partition(' ')
for errname in filter(None, errnames.strip().split(', ')): for errname in filter(None, errnames.strip().split(', ')):
if errname == "ENOTCAPABLE" and not hasattr(errno, errname):
continue
_map[getattr(errno, errname)] = getattr(builtins, excname) _map[getattr(errno, errname)] = getattr(builtins, excname)
return _map return _map
_map = _make_map(_pep_map) _map = _make_map(_pep_map)
@ -91,7 +93,7 @@ class HierarchyTest(unittest.TestCase):
othercodes = set(errno.errorcode) - set(self._map) othercodes = set(errno.errorcode) - set(self._map)
for errcode in othercodes: for errcode in othercodes:
e = OSError(errcode, "Some message") e = OSError(errcode, "Some message")
self.assertIs(type(e), OSError) self.assertIs(type(e), OSError, repr(e))
def test_try_except(self): def test_try_except(self):
filename = "some_hopefully_non_existing_file" filename = "some_hopefully_non_existing_file"