]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-25655: Improve Win DLL loading failures doc (GH-22372)
authorPhilippe Ombredanne <pombredanne@gmail.com>
Thu, 22 Oct 2020 15:39:18 +0000 (17:39 +0200)
committerGitHub <noreply@github.com>
Thu, 22 Oct 2020 15:39:18 +0000 (16:39 +0100)
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.

Doc/library/ctypes.rst

index c172d5377636a77f4747f2ad0b5d9ff78d45b3c7..bf32d3e549b4809f397fcafab40f79d37ed0ed91 100644 (file)
@@ -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)