Skip to content

gh-52008: document that absolute paths can break use_errno=True in ct…#146504

Open
Das-Chinmay wants to merge 3 commits intopython:mainfrom
Das-Chinmay:fix-ctypes-use-errno-docs
Open

gh-52008: document that absolute paths can break use_errno=True in ct…#146504
Das-Chinmay wants to merge 3 commits intopython:mainfrom
Das-Chinmay:fix-ctypes-use-errno-docs

Conversation

@Das-Chinmay
Copy link

@Das-Chinmay Das-Chinmay commented Mar 27, 2026

Loading a shared library via an absolute path (e.g. CDLL('/lib/libc.so.6'))
can cause use_errno=True to silently malfunction on Linux: dlopen may
return a separate instance of the library with its own errno variable, so
ctypes swaps the wrong one and get_errno() always returns 0.

Adds a .. note:: block to the use_errno parameter docs in
Doc/library/ctypes.rst warning about this and recommending the use of an
unqualified name or ctypes.util.find_library instead.

Fixes gh-52008

  • Base: python/cpython:main
  • Head: Das-Chinmay:fix-ctypes-use-errno-docs

📚 Documentation preview 📚: https://cpython-previews--146504.org.readthedocs.build/

… in ctypes

Loading a shared library via an absolute path (e.g. CDLL('/lib/libc.so.6'))
can cause use_errno=True to silently malfunction on Linux because dlopen may
return a separate library instance with its own errno variable.  Add a note
to the CDLL.use_errno parameter docs warning about this and recommending the
use of an unqualified name or ctypes.util.find_library instead.
@python-cla-bot
Copy link

python-cla-bot bot commented Mar 27, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[doc] ctypes: use_errno=True does not work

1 participant