From: Benjamin Peterson Date: Mon, 20 Jan 2014 05:10:23 +0000 (-0500) Subject: put notes in a ..note section X-Git-Tag: v2.7.8~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad715d9e97b3a3a01653c27fee4555f605164c4a;p=python put notes in a ..note section --- diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 2f9727679b..31d5b31d13 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1080,18 +1080,18 @@ As we can easily check, our array is sorted now:: 1 5 7 33 99 >>> -**Important notes for callback functions:** - -Make sure you keep references to CFUNCTYPE objects as long as they are used from -C code. :mod:`ctypes` doesn't, and if you don't, they may be garbage collected, -crashing your program when a callback is made. - -Also, note that if the callback function is called in a thread created outside -of Python's control (e.g. by the foreign code that calls the callback), ctypes -creates a new dummy Python thread on every invocation. This behavior is correct -for most purposes, but it means that values stored with `threading.local` will -*not* survive across different callbacks, even when those calls are made from -the same C thread. +.. note:: + + Make sure you keep references to :func:`CFUNCTYPE` objects as long as they + are used from C code. :mod:`ctypes` doesn't, and if you don't, they may be + garbage collected, crashing your program when a callback is made. + + Also, note that if the callback function is called in a thread created + outside of Python's control (e.g. by the foreign code that calls the + callback), ctypes creates a new dummy Python thread on every invocation. This + behavior is correct for most purposes, but it means that values stored with + `threading.local` will *not* survive across different callbacks, even when + those calls are made from the same C thread. .. _ctypes-accessing-values-exported-from-dlls: