diff --git a/stdlib/VERSIONS b/stdlib/VERSIONS index d396ce4d0560..bd1abd204885 100644 --- a/stdlib/VERSIONS +++ b/stdlib/VERSIONS @@ -27,6 +27,7 @@ _collections_abc: 3.3- _compat_pickle: 3.1- _compression: 3.5- _csv: 2.7- +_ctypes: 2.7- _curses: 2.7- _decimal: 3.3- _dummy_thread: 3.0-3.8 diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi new file mode 100644 index 000000000000..f05c8a0e41c0 --- /dev/null +++ b/stdlib/_ctypes.pyi @@ -0,0 +1,16 @@ +import sys +from ctypes import _CArgObject, _PointerLike +from typing_extensions import TypeAlias + +if sys.platform == "win32": + # Description, Source, HelpFile, HelpContext, scode + _COMError_Details: TypeAlias = tuple[str | None, str | None, str | None, int | None, int | None] + + class COMError(Exception): + hresult: int + text: str | None + details: _COMError_Details + + def __init__(self, hresult: int, text: str | None, details: _COMError_Details) -> None: ... + + def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ... diff --git a/tests/stubtest_allowlists/darwin.txt b/tests/stubtest_allowlists/darwin.txt index 6c4349dd4ff5..f9896b6edf19 100644 --- a/tests/stubtest_allowlists/darwin.txt +++ b/tests/stubtest_allowlists/darwin.txt @@ -26,6 +26,10 @@ selectors.DefaultSelector.fileno socket.PF_SYSTEM socket.SYSPROTO_CONTROL +_ctypes.dlclose +_ctypes.dlopen +_ctypes.dlsym + posix.NGROUPS_MAX posix.error.characters_written resource.error.characters_written diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index 91ea20cf7418..af5a21ef5be7 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -23,6 +23,10 @@ selectors.DefaultSelector.fileno spwd.struct_spwd.sp_nam spwd.struct_spwd.sp_pwd +_ctypes.dlclose +_ctypes.dlopen +_ctypes.dlsym + # ========== # Allowlist entries that cannot or should not be fixed # ========== diff --git a/tests/stubtest_allowlists/py311.txt b/tests/stubtest_allowlists/py311.txt index 729dbb27e142..551f14191cb3 100644 --- a/tests/stubtest_allowlists/py311.txt +++ b/tests/stubtest_allowlists/py311.txt @@ -12,6 +12,7 @@ _collections_abc.MappingView.__class_getitem__ _collections_abc.ValuesView.__reversed__ _csv.Reader _csv.Writer +_ctypes.CTYPES_MAX_ARGCOUNT _operator.attrgetter.__vectorcalloffset__ _operator.itemgetter.__vectorcalloffset__ argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 5f058072177d..aeccb4be26e0 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -339,6 +339,32 @@ turtle.ScrolledCanvas.onResize wave.Wave_read.initfp wave.Wave_write.initfp +_ctypes.Array +_ctypes.CFuncPtr +_ctypes.FUNCFLAG_CDECL +_ctypes.FUNCFLAG_PYTHONAPI +_ctypes.FUNCFLAG_USE_ERRNO +_ctypes.FUNCFLAG_USE_LASTERROR +_ctypes.POINTER +_ctypes.PyObj_FromPtr +_ctypes.Py_DECREF +_ctypes.Py_INCREF +_ctypes.RTLD_GLOBAL +_ctypes.RTLD_LOCAL +_ctypes.Structure +_ctypes.Union +_ctypes.addressof +_ctypes.alignment +_ctypes.buffer_info +_ctypes.byref +_ctypes.call_cdeclfunction +_ctypes.call_function +_ctypes.get_errno +_ctypes.pointer +_ctypes.resize +_ctypes.set_errno +_ctypes.sizeof + # ========== # Allowlist entries that cannot or should not be fixed # ========== diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index fadeac30eecf..0a6466f955be 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -26,6 +26,13 @@ ssl.SSLSocket.recvmsg ssl.SSLSocket.recvmsg_into ssl.SSLSocket.sendmsg winreg.HKEYType.handle +_ctypes.FUNCFLAG_HRESULT +_ctypes.FUNCFLAG_STDCALL +_ctypes.FormatError +_ctypes.FreeLibrary +_ctypes.LoadLibrary +_ctypes.get_last_error +_ctypes.set_last_error # ==========