bpo-25655: Improve Win DLL loading failures doc (GH-22372) · python/cpython@b6f2fc9

Original file line numberDiff line numberDiff line change

@@ -1326,6 +1326,21 @@ way is to instantiate one of the following classes:

13261326

libraries use the standard C calling convention, and are assumed to return

13271327

:c:type:`int`.

13281328
1329+

On Windows creating a :class:`CDLL` instance may fail even if the DLL name

1330+

exists. When a dependent DLL of the loaded DLL is not found, a

1331+

:exc:`OSError` error is raised with the message *"[WinError 126] The

1332+

specified module could not be found".* This error message does not contain

1333+

the name of the missing DLL because the Windows API does not return this

1334+

information making this error hard to diagnose. To resolve this error and

1335+

determine which DLL is not found, you need to find the list of dependent

1336+

DLLs and determine which one is not found using Windows debugging and

1337+

tracing tools.

1338+
1339+

.. seealso::

1340+
1341+

`Microsoft DUMPBIN tool <https://docs.microsoft.com/cpp/build/reference/dependents>`_

1342+

-- A tool to find DLL dependents.

1343+
13291344
13301345

.. class:: OleDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=0)

13311346