]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96005: FreeBSD has ENOTCAPABLE, too (GH-96034)
authorChristian Heimes <christian@python.org>
Wed, 17 Aug 2022 05:24:53 +0000 (07:24 +0200)
committerGitHub <noreply@github.com>
Wed, 17 Aug 2022 05:24:53 +0000 (07:24 +0200)
Doc/library/errno.rst
Lib/test/test_exception_hierarchy.py

index da4e964ac3f0c91535dfbcb1e3590626c47a41b8..5122c69697ef91416a8fd2bb2af7643cc0dd3b87 100644 (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
    :exc:`PermissionError`.
 
-   .. availability:: WASI
+   .. availability:: WASI, FreeBSD
 
    .. versionadded:: 3.11.1
index 89fe9ddcefba3ee14ec434474cc9800181eded99..3318fa8e7746f7a8f5dc4cf6cb5f7cabde24efb4 100644 (file)
@@ -63,7 +63,7 @@ class HierarchyTest(unittest.TestCase):
         +-- InterruptedError                                            EINTR
         +-- IsADirectoryError                                          EISDIR
         +-- NotADirectoryError                                        ENOTDIR
-        +-- PermissionError                                     EACCES, EPERM
+        +-- PermissionError                        EACCES, EPERM, ENOTCAPABLE
         +-- ProcessLookupError                                          ESRCH
         +-- TimeoutError                                            ETIMEDOUT
     """
@@ -75,6 +75,8 @@ class HierarchyTest(unittest.TestCase):
                 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 @@ class HierarchyTest(unittest.TestCase):
         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"