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

Original file line number Diff line number Diff line change
@@ -1326,6 +1326,21 @@ way is to instantiate one of the following classes:
1326 1326 libraries use the standard C calling convention, and are assumed to return
1327 1327 :c:type:`int`.
1328 1328
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 +
1329 1344
1330 1345 .. class:: OleDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=0)
1331 1346