https://github.com/python/cpython/commit/41a10efc6c7383fc01703d504fd0cee84014431e
commit: 41a10efc6c7383fc01703d504fd0cee84014431e
branch: main
author: Peter Bierma <[email protected]>
committer: ZeroIntensity <[email protected]>
date: 2026-10-12T17:27:55Z
summary:
gh-52008: Document that `ctypes.CDLL` can only observe `errno` from its own C
runtime (GH-159239)
files:
M Doc/library/ctypes.rst
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index c492451148341d..27eb15facd21bc 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1579,7 +1579,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]