Skip to content

Commit d0888f9

Browse files
[3.14] gh-52008: Document that ctypes.CDLL can only observe errno from its own C runtime (GH-159239) (GH-159243)
(cherry picked from commit 41a10ef) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
1 parent 18b1302 commit d0888f9

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
@@ -1626,7 +1626,10 @@ way is to instantiate :py:class:`CDLL` or one of its subclasses:
16261626
:mod:`!ctypes` maintains a thread-local copy of the system's :data:`errno`
16271627
variable; if you call foreign functions created with ``use_errno=True`` then the
16281628
:data:`errno` value before the function call is swapped with the ctypes private
1629-
copy, the same happens immediately after the function call.
1629+
copy, the same happens immediately after the function call. This mechanism only
1630+
works for libraries that use the same C runtime library as the interpreter itself.
1631+
A library linked against a different C runtime (for example, a different CRT on
1632+
Windows) has its own :data:`errno`, which :mod:`!ctypes` cannot observe.
16301633

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

0 commit comments

Comments
 (0)