From 1d69fb3675c66241e10b501acd680026d3de0417 Mon Sep 17 00:00:00 2001 From: Jun Komoda <45822440+junkmd@users.noreply.github.com> Date: Sun, 7 May 2023 12:04:16 +0900 Subject: [PATCH] fix `_ctypes.CFuncPtr` constructor args (#10154) * add a conditional branch for Windows only * fix argname spelling `vtlb_index` -> `vtbl_index` * add an overload for the case where no arguments are passed to the constructor * mark all of the arguments as positional-only --- stdlib/_ctypes.pyi | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 3e3c8d29a..a04ded570 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -102,13 +102,19 @@ class CFuncPtr(_PointerLike, _CData): errcheck: _ECT _flags_: ClassVar[int] # Abstract attribute that must be defined on subclasses @overload - def __init__(self, address: int) -> None: ... + def __init__(self) -> None: ... @overload - def __init__(self, callable: Callable[..., Any]) -> None: ... + def __init__(self, __address: int) -> None: ... @overload - def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] = ...) -> None: ... + def __init__(self, __callable: Callable[..., Any]) -> None: ... @overload - def __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: _Pointer[c_int] = ...) -> None: ... + def __init__(self, __func_spec: tuple[str | int, CDLL], __paramflags: tuple[_PF, ...] = ...) -> None: ... + if sys.platform == "win32": + @overload + def __init__( + self, __vtbl_index: int, __name: str, __paramflags: tuple[_PF, ...] = ..., __iid: _Pointer[c_int] = ... + ) -> None: ... + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class _CField: