From 1b9e90baabdb5584217e5dfecc53d0973eb1bdb1 Mon Sep 17 00:00:00 2001 From: Max Muoto Date: Sun, 14 Jul 2024 00:16:42 -0500 Subject: [PATCH] Use positional-only parameters for `ctypes` functions (#12341) --- stdlib/@tests/stubtest_allowlists/py313.txt | 10 ---------- stdlib/_ctypes.pyi | 15 +++++++-------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 7b253f536e85..6392ae374624 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -3,11 +3,6 @@ # ========================= # TODO: triage these new errors -_ctypes.POINTER -_ctypes.addressof -_ctypes.alignment -_ctypes.pointer -_ctypes.sizeof _thread.interrupt_main _thread.lock _thread.start_joinable_thread @@ -18,7 +13,6 @@ codecs.namereplace_errors codecs.replace_errors codecs.strict_errors codecs.xmlcharrefreplace_errors -ctypes.POINTER ctypes._endian.DEFAULT_MODE ctypes._endian.RTLD_GLOBAL ctypes._endian.RTLD_LOCAL @@ -26,13 +20,9 @@ ctypes._endian.SIZEOF_TIME_T ctypes._endian.cdll ctypes._endian.pydll ctypes._endian.pythonapi -ctypes.addressof -ctypes.alignment ctypes.c_char_p.from_param ctypes.c_void_p.from_param ctypes.c_wchar_p.from_param -ctypes.pointer -ctypes.sizeof ctypes.wintypes.PCHAR.from_param ctypes.wintypes.PWCHAR.from_param doctest.TestResults.__doc__ diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 4a944bd7dddc..5be81fa53823 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -64,7 +64,6 @@ class _CData(metaclass=_CDataMeta): # Structure.from_buffer(...) # valid at runtime # Structure(...).from_buffer(...) # invalid at runtime # - @classmethod def from_buffer(cls, source: WriteableBuffer, offset: int = ...) -> Self: ... @classmethod @@ -100,8 +99,8 @@ class _Pointer(_PointerLike, _CData, Generic[_CT]): def __getitem__(self, key: slice, /) -> list[Any]: ... def __setitem__(self, key: int, value: Any, /) -> None: ... -def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ... -def pointer(arg: _CT, /) -> _Pointer[_CT]: ... +def POINTER(type: type[_CT], /) -> type[_Pointer[_CT]]: ... +def pointer(obj: _CT, /) -> _Pointer[_CT]: ... class _CArgObject: ... @@ -203,9 +202,9 @@ class Array(_CData, Generic[_CT]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... -def addressof(obj: _CData) -> int: ... -def alignment(obj_or_type: _CData | type[_CData]) -> int: ... +def addressof(obj: _CData, /) -> int: ... +def alignment(obj_or_type: _CData | type[_CData], /) -> int: ... def get_errno() -> int: ... -def resize(obj: _CData, size: int) -> None: ... -def set_errno(value: int) -> int: ... -def sizeof(obj_or_type: _CData | type[_CData]) -> int: ... +def resize(obj: _CData, size: int, /) -> None: ... +def set_errno(value: int, /) -> int: ... +def sizeof(obj_or_type: _CData | type[_CData], /) -> int: ...