Skip to content

Commit 41a10ef

Browse files
gh-52008: Document that ctypes.CDLL can only observe errno from its own C runtime (GH-159239)
1 parent cfea838 commit 41a10ef

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎Doc/library/ctypes.rst‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,10 @@ way is to instantiate :py:class:`CDLL` or one of its subclasses:
15791579
:mod:`!ctypes` maintains a thread-local copy of the system's :data:`errno`
15801580
variable; if you call foreign functions created with ``use_errno=True`` then the
15811581
:data:`errno` value before the function call is swapped with the ctypes private
1582-
copy, the same happens immediately after the function call.
1582+
copy, the same happens immediately after the function call. This mechanism only
1583+
works for libraries that use the same C runtime library as the interpreter itself.
1584+
A library linked against a different C runtime (for example, a different CRT on
1585+
Windows) has its own :data:`errno`, which :mod:`!ctypes` cannot observe.
15831586

15841587
The function :func:`ctypes.get_errno` returns the value of the ctypes private
15851588
copy, and the function :func:`ctypes.set_errno` changes the ctypes private copy

0 commit comments

Comments
 (0)