Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add _ctypes.pyi #8582

Merged
merged 7 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys
from ctypes import _CArgObject, _PointerLike
from typing import Any
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: ...

def __getattr__(name: str) -> Any: ... # incomplete
hauntsaninja marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions tests/stubtest_allowlists/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/stubtest_allowlists/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ==========
Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions tests/stubtest_allowlists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ==========
Expand Down
7 changes: 7 additions & 0 deletions tests/stubtest_allowlists/win32.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ==========
Expand Down