You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our stub has a _FuncPointer class that doesn't exist at runtime. But in fact, the code returns a subclass of _ctypes.CFuncPtr, so why don't we use that class in the stubs?
In addition, Python's ctypes runtime namespace is defined by the following lines;
Quoting from #9251 (comment);
In addition, Python's
ctypes
runtime namespace is defined by the following lines;from _ctypes import CFuncPtr as _CFuncPtr
importing parthttps://github.com/python/cpython/blob/872cbc613245db7a1fc5e6656ed0135d2e115f50/Lib/ctypes/__init__.py#L10
Subclasses of
_ctypes.CFuncPtr
is created by the following linesDefinition of
CFUNCTYPE
, factory function that creates dynamicallyCFunctionType
classhttps://github.com/python/cpython/blob/872cbc613245db7a1fc5e6656ed0135d2e115f50/Lib/ctypes/__init__.py#L73-L107
Definition of
PYFUNCTYPE
, factory function that creates dynamicallyCFunctionType
classhttps://github.com/python/cpython/blob/872cbc613245db7a1fc5e6656ed0135d2e115f50/Lib/ctypes/__init__.py#L509-L514
Definition of
WINFUNCTYPE
, factory function that creates dynamicallyWinFunctionType
classhttps://github.com/python/cpython/blob/872cbc613245db7a1fc5e6656ed0135d2e115f50/Lib/ctypes/__init__.py#L114-L134
Definition of
CDLL
, its'__getitem__
and__getattr__
return_FuncPtr
classhttps://github.com/python/cpython/blob/872cbc613245db7a1fc5e6656ed0135d2e115f50/Lib/ctypes/__init__.py#L322-L400
I think the following way can be improved with less changes and less impact.
_FuncPointer
to_ctypes.pyi
.CFuncPtr
.from _ctypes import CFuncPtr as _CFuncPtr
line toctypes/__init__.pyi
.class _FuncPointer(_CFuncPtr): ...
line.The
ctypes._FuncPointer
will be conceptualized as "a dynamically generated subclass of_ctypes.CFuncPtr
".this issue is related to #8968, #8571 (comment) and #8633 (comment)
The text was updated successfully, but these errors were encountered: