Skip to content

Bump ctypes to 3.14 #14137

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

Merged
merged 6 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions stdlib/@tests/stubtest_allowlists/darwin-py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# ====================================================================

asyncio.tools
ctypes.c_double_complex._type_
ctypes.c_float_complex._type_
ctypes.c_longdouble_complex._type_


# =======
Expand Down
3 changes: 0 additions & 3 deletions stdlib/@tests/stubtest_allowlists/linux-py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@
# ====================================================================

asyncio.tools
ctypes.c_double_complex._type_
ctypes.c_float_complex._type_
ctypes.c_longdouble_complex._type_
11 changes: 0 additions & 11 deletions stdlib/@tests/stubtest_allowlists/py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ compression.gzip.GzipFile.readinto1
compression.gzip.GzipFile.readinto1
compression.gzip.compress
compression.zstd
ctypes.memoryview_at
ctypes.py_object.__class_getitem__
ctypes.util.dllist
ctypes.wintypes.HCONV
ctypes.wintypes.HCONVLIST
ctypes.wintypes.HCURSOR
ctypes.wintypes.HDDEDATA
ctypes.wintypes.HDROP
ctypes.wintypes.HFILE
ctypes.wintypes.HRESULT
ctypes.wintypes.HSZ
fractions.Fraction.__pow__
fractions.Fraction.__rpow__
gzip.GzipFile.readinto
Expand Down
3 changes: 0 additions & 3 deletions stdlib/@tests/stubtest_allowlists/win32-py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

_winapi.COPY_FILE_DIRECTORY
compression.zlib.ZLIBNG_VERSION
ctypes.c_double_complex
ctypes.c_float_complex
ctypes.c_longdouble_complex
encodings.win32_code_page_search_function
nt.readinto
pathlib.Path.group
Expand Down
2 changes: 2 additions & 0 deletions stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class _CData:
_objects: Mapping[Any, int] | None
def __buffer__(self, flags: int, /) -> memoryview: ...
def __ctypes_from_outparam__(self, /) -> Self: ...
if sys.version_info >= (3, 14):
__pointer_type__: type

# this is a union of all the subclasses of _CData, which is useful because of
# the methods that are present on each of those subclasses which are not present
Expand Down
20 changes: 14 additions & 6 deletions stdlib/ctypes/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ from typing_extensions import Self, TypeAlias, deprecated
if sys.platform == "win32":
from _ctypes import FormatError as FormatError, get_last_error as get_last_error, set_last_error as set_last_error

if sys.version_info >= (3, 14):
from _ctypes import COMError as COMError

if sys.version_info >= (3, 11):
from ctypes._endian import BigEndianUnion as BigEndianUnion, LittleEndianUnion as LittleEndianUnion

Expand Down Expand Up @@ -197,8 +200,13 @@ if sys.platform == "win32":

def wstring_at(ptr: _CVoidConstPLike, size: int = -1) -> str: ...

if sys.version_info >= (3, 14):
def memoryview_at(ptr: _CVoidConstPLike, size: int, readonly: bool = False) -> memoryview: ...

class py_object(_CanCastTo, _SimpleCData[_T]):
_type_: ClassVar[Literal["O"]]
if sys.version_info >= (3, 14):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

class c_bool(_SimpleCData[bool]):
_type_: ClassVar[Literal["?"]]
Expand Down Expand Up @@ -270,16 +278,16 @@ class c_double(_SimpleCData[float]):
class c_longdouble(_SimpleCData[float]): # can be an alias for c_double
_type_: ClassVar[Literal["d", "g"]]

if sys.version_info >= (3, 14):
class c_float_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["E"]]

if sys.version_info >= (3, 14) and sys.platform != "win32":
class c_double_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["C"]]
_type_: ClassVar[Literal["D"]]

class c_longdouble_complex(_SimpleCData[complex]):
class c_float_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["F"]]

class c_longdouble_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["G"]]

class c_char(_SimpleCData[bytes]):
_type_: ClassVar[Literal["c"]]
def __init__(self, value: int | bytes | bytearray = ...) -> None: ...
Expand Down
3 changes: 3 additions & 0 deletions stdlib/ctypes/util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ def find_library(name: str) -> str | None: ...
if sys.platform == "win32":
def find_msvcrt() -> str | None: ...

if sys.version_info >= (3, 14):
def dllist() -> list[str]: ...

def test() -> None: ...
9 changes: 9 additions & 0 deletions stdlib/ctypes/wintypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ HACCEL = HANDLE
HBITMAP = HANDLE
HBRUSH = HANDLE
HCOLORSPACE = HANDLE
if sys.version_info >= (3, 14):
HCONV = HANDLE
HCONVLIST = HANDLE
HCURSOR = HANDLE
HDDEDATA = HANDLE
HDROP = HANDLE
HFILE = INT
HRESULT = LONG
HSZ = HANDLE
HDC = HANDLE
HDESK = HANDLE
HDWP = HANDLE
Expand Down