@@ -871,6 +871,14 @@ invalid non-\ ``NULL`` pointers would crash Python)::
871871 ValueError: NULL pointer access
872872 >>>
873873
874+ .. _ctypes-pointers-ctypes-like-types :
875+
876+ Pointers for ctypes-like types
877+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
878+
879+ In some cases you want that :func: `POINTER ` can accept non-ctypes types. To do so
880+ just add to your types a class level attribute with the name ``__pointer_type__ ``.
881+
874882.. _ctypes-thread-safety :
875883
876884Thread safety without the GIL
@@ -2171,9 +2179,10 @@ Utility functions
21712179
21722180.. function :: POINTER(type, /)
21732181
2174- Create and return a new ctypes pointer type. Pointer types are cached and
2182+ Create or return a ctypes pointer type. Pointer types are cached and
21752183 reused internally, so calling this function repeatedly is cheap.
2176- *type * must be a ctypes type.
2184+ *type * must be a ctypes-like type. The ctypes-like type is a type that
2185+ has class level attribute with the name ``__pointer_type__ ``.
21772186
21782187
21792188.. function :: pointer(obj, /)
@@ -2360,6 +2369,14 @@ Data types
23602369 valid. This object is only exposed for debugging; never modify the
23612370 contents of this dictionary.
23622371
2372+ .. attribute :: __pointer_type__
2373+
2374+ This attributes is a pointer type that was created by calling
2375+ :func: `POINTER ` for corresponding ctypes data type. If ``POINTER `` was
2376+ not called then this attribute contains ``None ``.
2377+
2378+ .. versionadded :: 3.14
2379+
23632380
23642381.. _ctypes-fundamental-data-types-2 :
23652382
0 commit comments