From e0f42620cf717703d73b1fc79c106254093b8729 Mon Sep 17 00:00:00 2001 From: Anson Mansfield Date: Mon, 7 Apr 2025 11:29:29 -0400 Subject: [PATCH 1/2] cpydiff: Document lack of OSError errno subtype mapping. Signed-off-by: Anson Mansfield --- tests/cpydiff/types_oserror_errnomap.py | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/cpydiff/types_oserror_errnomap.py diff --git a/tests/cpydiff/types_oserror_errnomap.py b/tests/cpydiff/types_oserror_errnomap.py new file mode 100644 index 0000000000000..b2b7745056043 --- /dev/null +++ b/tests/cpydiff/types_oserror_errnomap.py @@ -0,0 +1,48 @@ +""" +categories: Types,OSError +description: OSError constructor returns a plain OSError for all errno values, rather than a relevant subtype. +cause: Micropython does not include the CPython-standard OSError subclasses. +workaround: Catch OSError and use its errno attribute to discriminate the cause. +""" + +import errno + +errno_list = [ # i.e. the set implemented by micropython + errno.EPERM, + errno.ENOENT, + errno.EIO, + errno.EBADF, + errno.EAGAIN, + errno.ENOMEM, + errno.EACCES, + errno.EEXIST, + errno.ENODEV, + errno.EISDIR, + errno.EINVAL, + errno.EOPNOTSUPP, + errno.EADDRINUSE, + errno.ECONNABORTED, + errno.ECONNRESET, + errno.ENOBUFS, + errno.ENOTCONN, + errno.ETIMEDOUT, + errno.ECONNREFUSED, + errno.EHOSTUNREACH, + errno.EALREADY, + errno.EINPROGRESS, +] + + +def errno_output_type(n): + try: + raise OSError(n, "") + except OSError as e: + return f"{type(e).__name__}" + except Exception as e: + return f"non-OSError {type(e).__name__}" + else: + return "no error" + + +for n in errno_list: + print(errno.errorcode[n], "=", errno_output_type(n)) From 90aa1703e41ecbf0dc03a1e3cfa654cab6cf31bd Mon Sep 17 00:00:00 2001 From: Anson Mansfield Date: Mon, 7 Apr 2025 11:11:58 -0400 Subject: [PATCH 2/2] cpydiff: Document ENOTSUP vs EOPNOTSUPP. Signed-off-by: Anson Mansfield --- tests/cpydiff/modules_errno_enotsup.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/cpydiff/modules_errno_enotsup.py diff --git a/tests/cpydiff/modules_errno_enotsup.py b/tests/cpydiff/modules_errno_enotsup.py new file mode 100644 index 0000000000000..28c494165e21c --- /dev/null +++ b/tests/cpydiff/modules_errno_enotsup.py @@ -0,0 +1,10 @@ +""" +categories: Modules,errno +description: Micropython does not include ``ENOTSUP`` as a name for errno 95. +cause: Micropython does not implement the ``ENOTSUP`` canonical alias for ``EOPNOTSUPP`` added in CPython 3.2. +workaround: Use ``errno.EOPNOTSUPP`` in place of ``errno.ENOTSUP``. +""" + +import errno + +print(f"{errno.errorcode[errno.EOPNOTSUPP]=!s}") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy