From f812d71ffa2662a0291f8e5e32a7e2ff082a8af1 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 26 Jun 2022 03:59:02 +0100 Subject: [PATCH] Improve `errno` stubs on Windows and MacOS (#8142) --- stdlib/errno.pyi | 196 +++++++++++++++-------- tests/stubtest_allowlists/linux.txt | 1 + tests/stubtest_allowlists/py3_common.txt | 1 - 3 files changed, 130 insertions(+), 68 deletions(-) diff --git a/stdlib/errno.pyi b/stdlib/errno.pyi index 9ef1fe6e7..28874d44f 100644 --- a/stdlib/errno.pyi +++ b/stdlib/errno.pyi @@ -1,3 +1,4 @@ +import sys from collections.abc import Mapping errorcode: Mapping[int, str] @@ -16,7 +17,6 @@ EAGAIN: int ENOMEM: int EACCES: int EFAULT: int -ENOTBLK: int EBUSY: int EEXIST: int EXDEV: int @@ -45,49 +45,16 @@ ELOOP: int EWOULDBLOCK: int ENOMSG: int EIDRM: int -ECHRNG: int -EL2NSYNC: int -EL3HLT: int -EL3RST: int -ELNRNG: int -EUNATCH: int -ENOCSI: int -EL2HLT: int -EBADE: int -EBADR: int -EXFULL: int -ENOANO: int -EBADRQC: int -EBADSLT: int -EDEADLOCK: int -EBFONT: int ENOSTR: int ENODATA: int ETIME: int ENOSR: int -ENONET: int -ENOPKG: int EREMOTE: int ENOLINK: int -EADV: int -ESRMNT: int -ECOMM: int EPROTO: int -EMULTIHOP: int -EDOTDOT: int EBADMSG: int EOVERFLOW: int -ENOTUNIQ: int -EBADFD: int -EREMCHG: int -ELIBACC: int -ELIBBAD: int -ELIBSCN: int -ELIBMAX: int -ELIBEXEC: int EILSEQ: int -ERESTART: int -ESTRPIPE: int EUSERS: int ENOTSOCK: int EDESTADDRREQ: int @@ -119,40 +86,135 @@ EHOSTUNREACH: int EALREADY: int EINPROGRESS: int ESTALE: int -EUCLEAN: int -ENOTNAM: int -ENAVAIL: int -EISNAM: int -EREMOTEIO: int EDQUOT: int ECANCELED: int # undocumented -EKEYEXPIRED: int # undocumented -EKEYREJECTED: int # undocumented -EKEYREVOKED: int # undocumented -EMEDIUMTYPE: int # undocumented -ENOKEY: int # undocumented -ENOMEDIUM: int # undocumented ENOTRECOVERABLE: int # undocumented EOWNERDEAD: int # undocumented -ERFKILL: int # undocumented -EAUTH: int # undocumented -EBADARCH: int # undocumented -EBADEXEC: int # undocumented -EBADMACHO: int # undocumented -EBADRPC: int # undocumented -EDEVERR: int # undocumented -EFTYPE: int # undocumented -EL: int # undocumented -ELOCKUNMAPPED: int # undocumented -ENEEDAUTH: int # undocumented -ENOATTR: int # undocumented -ENOPOLICY: int # undocumented -ENOTACTIVE: int # undocumented -EPROCLIM: int # undocumented -EPROCUNAVAIL: int # undocumented -EPROGMISMATCH: int # undocumented -EPROGUNAVAIL: int # undocumented -EPWROFF: int # undocumented -EQFULL: int # undocumented -ERPCMISMATCH: int # undocumented -ESHLIBVERS: int # undocumented + +if sys.platform != "win32": + ENOTBLK: int + EMULTIHOP: int + # All of the below are undocumented + EAUTH: int + EBADARCH: int + EBADEXEC: int + EBADMACHO: int + EBADRPC: int + EDEVERR: int + EFTYPE: int + ENEEDAUTH: int + ENOATTR: int + ENOPOLICY: int + EPROCLIM: int + EPROCUNAVAIL: int + EPROGMISMATCH: int + EPROGUNAVAIL: int + EPWROFF: int + ERPCMISMATCH: int + ESHLIBVERS: int + + if sys.platform != "darwin" or sys.version_info >= (3, 11): + EQFULL: int # undocumented + +if sys.platform != "darwin": + EDEADLOCK: int + +if sys.platform != "win32" and sys.platform != "darwin": + ECHRNG: int + EL2NSYNC: int + EL3HLT: int + EL3RST: int + ELNRNG: int + EUNATCH: int + ENOCSI: int + EL2HLT: int + EBADE: int + EBADR: int + EXFULL: int + ENOANO: int + EBADRQC: int + EBADSLT: int + EBFONT: int + ENONET: int + ENOPKG: int + EADV: int + ESRMNT: int + ECOMM: int + EDOTDOT: int + ENOTUNIQ: int + EBADFD: int + EREMCHG: int + ELIBACC: int + ELIBBAD: int + ELIBSCN: int + ELIBMAX: int + ELIBEXEC: int + ERESTART: int + ESTRPIPE: int + EUCLEAN: int + ENOTNAM: int + ENAVAIL: int + EISNAM: int + EREMOTEIO: int + # All of the below are undocumented + EKEYEXPIRED: int + EKEYREJECTED: int + EKEYREVOKED: int + EMEDIUMTYPE: int + ENOKEY: int + ENOMEDIUM: int + ERFKILL: int + EL: int + ELOCKUNMAPPED: int + ENOTACTIVE: int + +if sys.platform == "win32": + # All of these are undocumented + WSABASEERR: int + WSAEACCES: int + WSAEADDRINUSE: int + WSAEADDRNOTAVAIL: int + WSAEAFNOSUPPORT: int + WSAEALREADY: int + WSAEBADF: int + WSAECONNABORTED: int + WSAECONNREFUSED: int + WSAECONNRESET: int + WSAEDESTADDRREQ: int + WSAEDISCON: int + WSAEDQUOT: int + WSAEFAULT: int + WSAEHOSTDOWN: int + WSAEHOSTUNREACH: int + WSAEINPROGRESS: int + WSAEINTR: int + WSAEINVAL: int + WSAEISCONN: int + WSAELOOP: int + WSAEMFILE: int + WSAEMSGSIZE: int + WSAENAMETOOLONG: int + WSAENETDOWN: int + WSAENETRESET: int + WSAENETUNREACH: int + WSAENOBUFS: int + WSAENOPROTOOPT: int + WSAENOTCONN: int + WSAENOTEMPTY: int + WSAENOTSOCK: int + WSAEOPNOTSUPP: int + WSAEPFNOSUPPORT: int + WSAEPROCLIM: int + WSAEPROTONOSUPPORT: int + WSAEPROTOTYPE: int + WSAEREMOTE: int + WSAESHUTDOWN: int + WSAESOCKTNOSUPPORT: int + WSAESTALE: int + WSAETIMEDOUT: int + WSAETOOMANYREFS: int + WSAEUSERS: int + WSAEWOULDBLOCK: int + WSANOTINITIALISED: int + WSASYSNOTREADY: int + WSAVERNOTSUPPORTED: int diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index b9ff3100c..c38a121f0 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -12,6 +12,7 @@ selectors.KqueueSelector signal.SIGEMT signal.SIGINFO socket.[A-Z0-9_]+ +errno.[A-Z0-9]+ # Exists at runtime, but missing from stubs distutils.msvccompiler.MSVCCompiler.get_msvc_paths diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 8d30690c1..148809817 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -519,7 +519,6 @@ xml.etree xml.sax # Platform differences that cannot be captured by the type system -errno.[A-Z0-9]+ os.O_[A-Z_]+ (posix.O_[A-Z_]+)? (posix.ST_[A-Z]+)?