[Python-checkins] gh-96005: FreeBSD has ENOTCAPABLE, too (GH-96034)

tiran webhook-mailer at python.org
Wed Aug 17 01:24:58 EDT 2022


https://github.com/python/cpython/commit/da0aa518bf5e6ac9de444a405c40649cfb0245eb
commit: da0aa518bf5e6ac9de444a405c40649cfb0245eb
branch: main
author: Christian Heimes <christian at python.org>
committer: tiran <christian at python.org>
date: 2022-08-17T07:24:53+02:00
summary:

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

files:
M Doc/library/errno.rst
M Lib/test/test_exception_hierarchy.py

diff --git a/Doc/library/errno.rst b/Doc/library/errno.rst
index da4e964ac3f..5122c69697e 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 89fe9ddcefb..3318fa8e774 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"



More information about the Python-checkins mailing list