8000 move some non-pointer-related definitions from `ctypes/__init__.pyi` … · python/typeshed@ce531f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce531f8

Browse files
authored
move some non-pointer-related definitions from ctypes/__init__.pyi to _ctypes.pyi (#10130)
- `ArgumentError` - `addressof` - `alignment` - `get_errno` - `resize` - `set_errno` - `sizeof`
1 parent 1caac91 commit ce531f8

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

stdlib/_ctypes.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,12 @@ class Array(Generic[_CT], _CData):
132132
def __len__(self) -> int: ...
133133
if sys.version_info >= (3, 9):
134134
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
135+
136+
class ArgumentError(Exception): ...
137+
138+
def addressof(obj: _CData) -> int: ...
139+
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
140+
def get_errno() -> int: ...
141+
def resize(obj: _CData, size: int) -> None: ...
142+
def set_errno(value: int) -> int: ...
143+
def sizeof(obj_or_type: _CData | type[_CData]) -> int: ...

stdlib/ctypes/__init__.pyi

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import sys
22
from _ctypes import (
33
RTLD_GLOBAL as RTLD_GLOBAL,
44
RTLD_LOCAL as RTLD_LOCAL,
5+
ArgumentError as ArgumentError,
56
Array as Array,
67
Structure as Structure,
78
Union as Union,
@@ -11,6 +12,12 @@ from _ctypes import (
1112
_SimpleCData as _SimpleCData,
1213
_StructUnionBase as _StructUnionBase,
1314
_StructUnionMeta as _StructUnionMeta,
15+
addressof as addressof,
16+
alignment as alignment,
17+
get_errno as get_errno,
18+
resize as resize,
19+
set_errno as set_errno,
20+
sizeof as sizeof,
1421
)
1522
from collections.abc import Callable, Sequence
1623
from typing import Any, ClassVar, Generic, TypeVar, overload
@@ -101,8 +108,6 @@ class _FuncPointer(_PointerLike, _CData):
101108
class _NamedFuncPointer(_FuncPointer):
102109
__name__: str
103110

104-
class ArgumentError(Exception): ...
105-
106111
def CFUNCTYPE(
107112
restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ...
108113
) -> type[_FuncPointer]: ...
@@ -125,8 +130,6 @@ _CVoidPLike: TypeAlias = _PointerLike | Array[Any] | _CArgObject | int
125130
# when memmove(buf, b'foo', 4) was intended.
126131
_CVoidConstPLike: TypeAlias = _CVoidPLike | bytes
127132

128-
def addressof(obj: _CData) -> int: ...
129-
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
130133
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
131134

132135
_CastT = TypeVar("_CastT", bound=_CanCastTo)
@@ -143,7 +146,6 @@ if sys.platform == "win32":
143146
def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented
144147
def GetLastError() -> int: ...
145148

146-
def get_errno() -> int: ...
147149
def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> int: ...
148150
def memset(dst: _CVoidPLike, c: int, count: int) -> int: ...
149151
def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ...
@@ -162,9 +164,6 @@ class _Pointer(Generic[_CT], _PointerLike, _CData):
162164
def __setitem__(self, __key: int, __value: Any) -> None: ...
163165

164166
def pointer(__arg: _CT) -> _Pointer[_CT]: ...
165-
def resize(obj: _CData, size: int) -> None: ...
166-
def set_errno(value: int) -> int: ...
167-
def sizeof(obj_or_type: _CData | type[_CData]) -> int: ...
168167
def string_at(address: _CVoidConstPLike, size: int = -1) -> bytes: ...
169168

170169
if sys.platform == "win32":

tests/stubtest_allowlists/py3_common.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,11 @@ _ctypes.POINTER
339339
_ctypes.PyObj_FromPtr
340340
_ctypes.Py_DECREF
341341
_ctypes.Py_INCREF
342-
_ctypes.addressof
343-
_ctypes.alignment
344342
_ctypes.buffer_info
345343
_ctypes.byref
346344
_ctypes.call_cdeclfunction
347345
_ctypes.call_function
348-
_ctypes.get_errno
349346
_ctypes.pointer
350-
_ctypes.resize
351-
_ctypes.set_errno
352-
_ctypes.sizeof
353347

354348
# ==========
355349
# Allowlist entries that cannot or should not be fixed

0 commit comments

Comments
 (0)
0