]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] Add a prominent crash warning to the `ctypes` docs (GH-150410)
authorStan Ulbrych <stan@python.org>
Thu, 28 May 2026 15:01:15 +0000 (16:01 +0100)
committerGitHub <noreply@github.com>
Thu, 28 May 2026 15:01:15 +0000 (15:01 +0000)
(cherry picked from commit b53f6ca850b500621474e82931c3e7216d9a1cb1)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Doc/library/ctypes.rst

index d9cd5f2e265a95f4fc36682f9d228316b271ad53..96f6a1e740a17a2f04197681c8c09ff569bc901e 100644 (file)
 data types, and allows calling functions in DLLs or shared libraries.  It can be
 used to wrap these libraries in pure Python.
 
+.. warning::
+
+   :mod:`!ctypes` provides low-level access to native libraries and the
+   process's memory, bypassing Python's safety mechanisms and allowing
+   execution of arbitrary native code.
+   Incorrect use can corrupt data and objects, reveal sensitive information,
+   cause crashes, or otherwise compromise the running process.
+
 
 .. _ctypes-ctypes-tutorial:
 
@@ -190,10 +198,8 @@ argument values::
    OSError: exception: access violation reading 0x00000020
    >>>
 
-There are, however, enough ways to crash Python with :mod:`ctypes`, so you
-should be careful anyway.  The :mod:`faulthandler` module can be helpful in
-debugging crashes (e.g. from segmentation faults produced by erroneous C library
-calls).
+The :mod:`faulthandler` module can help debug crashes,
+such as segmentation faults produced by erroneous C library calls.
 
 ``None``, integers, bytes objects and (unicode) strings are the only native
 Python objects that can directly be used as parameters in these function calls.