Move some Windows-specific things from ctypes/__init__.pyi to _ctypes.pyi (#10128)

- `FormatError`
- `get_last_error`
- `set_last_error`
This commit is contained in:
Jun Komoda
2023-05-02 19:21:55 +09:00
committed by GitHub
parent d208d5a833
commit bbeec7cbbf
3 changed files with 7 additions and 12 deletions

View File

@@ -16,6 +16,9 @@ from collections.abc import Callable, Sequence
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing_extensions import TypeAlias
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, 9):
from types import GenericAlias
@@ -138,14 +141,9 @@ def create_unicode_buffer(init: int | str, size: int | None = None) -> Array[c_w
if sys.platform == "win32":
def DllCanUnloadNow() -> int: ...
def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented
def FormatError(code: int = ...) -> str: ...
def GetLastError() -> int: ...
def get_errno() -> int: ...
if sys.platform == "win32":
def get_last_error() -> int: ...
def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> int: ...
def memset(dst: _CVoidPLike, c: int, count: int) -> int: ...
def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ...
@@ -166,10 +164,6 @@ class _Pointer(Generic[_CT], _PointerLike, _CData):
def pointer(__arg: _CT) -> _Pointer[_CT]: ...
def resize(obj: _CData, size: int) -> None: ...
def set_errno(value: int) -> int: ...
if sys.platform == "win32":
def set_last_error(value: int) -> int: ...
def sizeof(obj_or_type: _CData | type[_CData]) -> int: ...
def string_at(address: _CVoidConstPLike, size: int = -1) -> bytes: ...