Skip to content

Commit 2066b95

Browse files
junkmdhauntsaninja
andauthored
_ctypes: add stubs (#8582)
Co-authored-by: Shantanu <[email protected]> Co-authored-by: hauntsaninja <[email protected]>
1 parent 1e33759 commit 2066b95

File tree

7 files changed

+59
-0
lines changed

7 files changed

+59
-0
lines changed

stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ _collections_abc: 3.3-
2727
_compat_pickle: 3.1-
2828
_compression: 3.5-
2929
_csv: 2.7-
30+
_ctypes: 2.7-
3031
_curses: 2.7-
3132
_decimal: 3.3-
3233
_dummy_thread: 3.0-3.8

stdlib/_ctypes.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
from ctypes import _CArgObject, _PointerLike
3+
from typing_extensions import TypeAlias
4+
5+
if sys.platform == "win32":
6+
# Description, Source, HelpFile, HelpContext, scode
7+
_COMError_Details: TypeAlias = tuple[str | None, str | None, str | None, int | None, int | None]
8+
9+
class COMError(Exception):
10+
hresult: int
11+
text: str | None
12+
details: _COMError_Details
13+
14+
def __init__(self, hresult: int, text: str | None, details: _COMError_Details) -> None: ...
15+
16+
def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ...

tests/stubtest_allowlists/darwin.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ selectors.DefaultSelector.fileno
2626
socket.PF_SYSTEM
2727
socket.SYSPROTO_CONTROL
2828

29+
_ctypes.dlclose
30+
_ctypes.dlopen
31+
_ctypes.dlsym
32+
2933
posix.NGROUPS_MAX
3034
posix.error.characters_written
3135
resource.error.characters_written

tests/stubtest_allowlists/linux.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ selectors.DefaultSelector.fileno
2323
spwd.struct_spwd.sp_nam
2424
spwd.struct_spwd.sp_pwd
2525

26+
_ctypes.dlclose
27+
_ctypes.dlopen
28+
_ctypes.dlsym
29+
2630
# ==========
2731
# Allowlist entries that cannot or should not be fixed
2832
# ==========

tests/stubtest_allowlists/py311.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _collections_abc.MappingView.__class_getitem__
1212
_collections_abc.ValuesView.__reversed__
1313
_csv.Reader
1414
_csv.Writer
15+
_ctypes.CTYPES_MAX_ARGCOUNT
1516
_operator.attrgetter.__vectorcalloffset__
1617
_operator.itemgetter.__vectorcalloffset__
1718
argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group

tests/stubtest_allowlists/py3_common.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,32 @@ turtle.ScrolledCanvas.onResize
339339
wave.Wave_read.initfp
340340
wave.Wave_write.initfp
341341

342+
_ctypes.Array
343+
_ctypes.CFuncPtr
344+
_ctypes.FUNCFLAG_CDECL
345+
_ctypes.FUNCFLAG_PYTHONAPI
346+
_ctypes.FUNCFLAG_USE_ERRNO
347+
_ctypes.FUNCFLAG_USE_LASTERROR
348+
_ctypes.POINTER
349+
_ctypes.PyObj_FromPtr
350+
_ctypes.Py_DECREF
351+
_ctypes.Py_INCREF
352+
_ctypes.RTLD_GLOBAL
353+
_ctypes.RTLD_LOCAL
354+
_ctypes.Structure
355+
_ctypes.Union
356+
_ctypes.addressof
357+
_ctypes.alignment
358+
_ctypes.buffer_info
359+
_ctypes.byref
360+
_ctypes.call_cdeclfunction
361+
_ctypes.call_function
362+
_ctypes.get_errno
363+
_ctypes.pointer
364+
_ctypes.resize
365+
_ctypes.set_errno
366+
_ctypes.sizeof
367+
342368
# ==========
343369
# Allowlist entries that cannot or should not be fixed
344370
# ==========

tests/stubtest_allowlists/win32.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ ssl.SSLSocket.recvmsg
2626
ssl.SSLSocket.recvmsg_into
2727
ssl.SSLSocket.sendmsg
2828
winreg.HKEYType.handle
29+
_ctypes.FUNCFLAG_HRESULT
30+
_ctypes.FUNCFLAG_STDCALL
31+
_ctypes.FormatError
32+
_ctypes.FreeLibrary
33+
_ctypes.LoadLibrary
34+
_ctypes.get_last_error
35+
_ctypes.set_last_error
2936

3037

3138
# ==========

0 commit comments

Comments
 (0)