Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,15 @@ Generally you only use this feature if you receive a pointer from a C function,
and you *know* that the pointer actually points to an array instead of a single
item.

.. warning::

Because pointer objects support subscription, they implicitly support
:term:`iteration <iterator>`. Unless doing this in a controlled manner,
such as by manually calling :func:`next` on a :func:`pointer` iterator, this
will typically lead to infinite loops or crashes, because ctypes has no way
of knowing when to stop iteration. In other words, a ``pointer`` iterator
will infinitely yield arbitrary memory.

Behind the scenes, the :func:`pointer` function does more than simply create
pointer instances, it has to create pointer *types* first. This is done with the
:func:`POINTER` function, which accepts any :mod:`!ctypes` type, and returns a
Expand Down
Loading