https://github.com/python/cpython/commit/0073717076a480132938f3a9e3ae9797eb5ab4d1 commit: 0073717076a480132938f3a9e3ae9797eb5ab4d1 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity <[email protected]> date: 2026-10-12T17:36:02Z summary:
[3.15] gh-52008: Document that `ctypes.CDLL` can only observe `errno` from its own C runtime (GH-159239) (GH-159242) (cherry picked from commit 41a10efc6c7383fc01703d504fd0cee84014431e) 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 cc573936e4f4a6..f4ed861c35d28e 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1537,7 +1537,10 @@ way is to instantiate :py:class:`CDLL` or one of its subclasses: :mod:`!ctypes` maintains a thread-local copy of the system's :data:`errno` variable; if you call foreign functions created with ``use_errno=True`` then the :data:`errno` value before the function call is swapped with the ctypes private - copy, the same happens immediately after the function call. + copy, the same happens immediately after the function call. This mechanism only + works for libraries that use the same C runtime library as the interpreter itself. + A library linked against a different C runtime (for example, a different CRT on + Windows) has its own :data:`errno`, which :mod:`!ctypes` cannot observe. The function :func:`ctypes.get_errno` returns the value of the ctypes private copy, and the function :func:`ctypes.set_errno` changes the ctypes private copy _______________________________________________ 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]
