mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
ctypes: improve bytes handling (#9029)
This commit is contained in:
@@ -194,7 +194,7 @@ class _SimpleCData(Generic[_T], _CData):
|
||||
class c_byte(_SimpleCData[int]): ...
|
||||
|
||||
class c_char(_SimpleCData[bytes]):
|
||||
def __init__(self, value: int | bytes = ...) -> None: ...
|
||||
def __init__(self, value: int | bytes | bytearray = ...) -> None: ...
|
||||
|
||||
class c_char_p(_PointerLike, _SimpleCData[bytes | None]):
|
||||
def __init__(self, value: int | bytes | None = ...) -> None: ...
|
||||
@@ -266,7 +266,11 @@ class Array(Generic[_CT], _CData):
|
||||
def _type_(self) -> type[_CT]: ...
|
||||
@_type_.setter
|
||||
def _type_(self, value: type[_CT]) -> None: ...
|
||||
raw: bytes # Note: only available if _CT == c_char
|
||||
# Note: only available if _CT == c_char
|
||||
@property
|
||||
def raw(self) -> bytes: ...
|
||||
@raw.setter
|
||||
def raw(self, value: ReadableBuffer) -> None: ...
|
||||
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
|
||||
# TODO These methods cannot be annotated correctly at the moment.
|
||||
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
|
||||
|
||||
@@ -367,6 +367,8 @@ _ctypes.sizeof
|
||||
# Allowlist entries that cannot or should not be fixed
|
||||
# ==========
|
||||
|
||||
ctypes.Array.raw # exists but stubtest can't see it; only available if _CT == c_char
|
||||
|
||||
_collections_abc.AsyncGenerator.asend # async at runtime, deliberately not in the stub, see #7491. Pos-only differences also.
|
||||
_collections_abc.AsyncGenerator.__anext__ # async at runtime, deliberately not in the stub, see #7491
|
||||
_collections_abc.AsyncGenerator.aclose # async at runtime, deliberately not in the stub, see #7491
|
||||
|
||||
Reference in New Issue
Block a user