ctypes: allow cast() 1st argument to be int and 2nd argument to be Type[py_object] (#4311)

This commit is contained in:
Joshua Oreman
2020-07-10 01:44:23 -07:00
committed by GitHub
parent 209b6bb127
commit e6736cde8d

View File

@@ -96,7 +96,8 @@ class _CData(metaclass=_CDataMeta):
@classmethod
def in_dll(cls: Type[_CT], library: CDLL, name: str) -> _CT: ...
class _PointerLike(_CData): ...
class _CanCastTo(_CData): ...
class _PointerLike(_CanCastTo): ...
_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, Tuple[_CData, ...]], _CData]
_PF = _UnionT[Tuple[int], Tuple[int, str], Tuple[int, str, Any]]
@@ -143,9 +144,9 @@ def addressof(obj: _CData) -> int: ...
def alignment(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ...
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
_PT = TypeVar("_PT", bound=_PointerLike)
_CastT = TypeVar("_CastT", bound=_CanCastTo)
def cast(obj: _UnionT[_CData, _CArgObject], type: Type[_PT]) -> _PT: ...
def cast(obj: _UnionT[_CData, _CArgObject, int], type: Type[_CastT]) -> _CastT: ...
def create_string_buffer(init_or_size: _UnionT[int, bytes], size: Optional[int] = ...) -> Array[c_char]: ...
c_buffer = create_string_buffer
@@ -247,7 +248,7 @@ class c_bool(_SimpleCData[bool]):
if sys.platform == "win32":
class HRESULT(_SimpleCData[int]): ... # TODO undocumented
class py_object(_SimpleCData[_T]): ...
class py_object(_CanCastTo, _SimpleCData[_T]): ...
class _CField:
offset: int = ...