11import sys
22from _ctypes import (
3- POINTER as POINTER ,
43 RTLD_GLOBAL as RTLD_GLOBAL ,
54 RTLD_LOCAL as RTLD_LOCAL ,
65 Array as Array ,
@@ -19,15 +18,14 @@ from _ctypes import (
1918 alignment as alignment ,
2019 byref as byref ,
2120 get_errno as get_errno ,
22- pointer as pointer ,
2321 resize as resize ,
2422 set_errno as set_errno ,
2523 sizeof as sizeof ,
2624)
2725from _typeshed import StrPath
2826from ctypes ._endian import BigEndianStructure as BigEndianStructure , LittleEndianStructure as LittleEndianStructure
2927from types import GenericAlias
30- from typing import Any , ClassVar , Generic , Literal , TypeVar , type_check_only
28+ from typing import Any , ClassVar , Generic , Literal , TypeVar , overload , type_check_only
3129from typing_extensions import Self , TypeAlias , deprecated
3230
3331if sys .platform == "win32" :
@@ -36,9 +34,22 @@ if sys.platform == "win32":
3634if sys .version_info >= (3 , 11 ):
3735 from ctypes ._endian import BigEndianUnion as BigEndianUnion , LittleEndianUnion as LittleEndianUnion
3836
37+ _CT = TypeVar ("_CT" , bound = _CData )
3938_T = TypeVar ("_T" , default = Any )
4039_DLLT = TypeVar ("_DLLT" , bound = CDLL )
41- _CT = TypeVar ("_CT" , bound = _CData )
40+
41+ if sys .version_info >= (3 , 14 ):
42+ @overload
43+ @deprecated ("ctypes.POINTER with string" )
44+ def POINTER (obj : str ) -> type [Any ]: ...
45+ @overload
46+ def POINTER (obj : None ) -> type [c_void_p ]: ...
47+ @overload
48+ def POINTER (obj : type [_CT ]) -> type [_Pointer [_CT ]]: ...
49+ def pointer (obj : _CT ) -> _Pointer [_CT ]: ...
50+
51+ else :
52+ from _ctypes import POINTER as POINTER , pointer as pointer
4253
4354DEFAULT_MODE : int
4455
@@ -148,7 +159,7 @@ c_buffer = create_string_buffer
148159
149160def create_unicode_buffer (init : int | str , size : int | None = None ) -> Array [c_wchar ]: ...
150161@deprecated ("Deprecated in Python 3.13; removal scheduled for Python 3.15" )
151- def SetPointerType (pointer : type [_Pointer [Any ]], cls : Any ) -> None : ... # noqa: F811
162+ def SetPointerType (pointer : type [_Pointer [Any ]], cls : Any ) -> None : ...
152163def ARRAY (typ : _CT , len : int ) -> Array [_CT ]: ... # Soft Deprecated, no plans to remove
153164
154165if sys .platform == "win32" :
0 commit comments