https://github.com/python/cpython/commit/625519fcbe57417c8158b2c02e2876e15a2615dd
commit: 625519fcbe57417c8158b2c02e2876e15a2615dd
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: ZeroIntensity <[email protected]>
date: 2026-10-19T19:29:49Z
summary:

[3.15] gh-114150: Clarify that `ctypes.PYFUNCTYPE` can release the GIL during 
the call (GH-114151) (GH-159734)

(cherry picked from commit d42178a811d05c0ad3623034a12ff018a07e7ec7)

Co-authored-by: arrmansa <[email protected]>
Co-authored-by: Peter Bierma <[email protected]>

files:
M Doc/library/ctypes.rst

diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index f4ed861c35d28e..9cfa3e069bd8a3 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -2006,7 +2006,11 @@ See :ref:`ctypes-callback-functions` for examples.
 .. function:: PYFUNCTYPE(restype, *argtypes)
 
    The returned function prototype creates functions that use the Python 
calling
-   convention.  The function will *not* release the GIL during the call.
+   convention.  Unlike :func:`CFUNCTYPE` and :func:`WINFUNCTYPE`, ctypes does
+   *not* release the GIL before calling the foreign function, so the function
+   may safely use the Python C API. Note that this does not prevent the GIL
+   from being released *during* the call.
+
 
 Function prototypes created by these factory functions can be instantiated in
 different ways, depending on the type and number of the parameters in the call:

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to