[Python-checkins] bpo-25655: Improve Win DLL loading failures doc (GH-22372)

miss-islington webhook-mailer at python.org
Thu Oct 22 12:02:23 EDT 2020


https://github.com/python/cpython/commit/f22f874a66d6ddb32fa74ad4325199db7e4c25fd
commit: f22f874a66d6ddb32fa74ad4325199db7e4c25fd
branch: 3.9
author: Miss Skeleton (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2020-10-22T09:02:13-07:00
summary:

bpo-25655: Improve Win DLL loading failures doc (GH-22372)


Add documentation to help diagnose CDLL dependent DLL loading errors
on windows for OSError with message:
"[WinError 126] The specified module could not be found"
This error is otherwise difficult to diagnose.
(cherry picked from commit b6f2fc90409e291822166d74ce7402e0ef4dba91)

Co-authored-by: Philippe Ombredanne <pombredanne at gmail.com>

files:
M Doc/library/ctypes.rst

diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index c172d5377636a..bf32d3e549b48 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1326,6 +1326,21 @@ way is to instantiate one of the following classes:
    libraries use the standard C calling convention, and are assumed to return
    :c:type:`int`.
 
+   On Windows creating a :class:`CDLL` instance may fail even if the DLL name
+   exists. When a dependent DLL of the loaded DLL is not found, a
+   :exc:`OSError` error is raised with the message *"[WinError 126] The
+   specified module could not be found".* This error message does not contain
+   the name of the missing DLL because the Windows API does not return this
+   information making this error hard to diagnose. To resolve this error and
+   determine which DLL is not found, you need to find the list of dependent
+   DLLs and determine which one is not found using Windows debugging and
+   tracing tools.
+
+.. seealso::
+
+    `Microsoft DUMPBIN tool <https://docs.microsoft.com/cpp/build/reference/dependents>`_
+    -- A tool to find DLL dependents.
+
 
 .. class:: OleDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=0)
 



More information about the Python-checkins mailing list