From 4454d2a3754af406592d66838b4c4915186e118a Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Wed, 23 Sep 2020 10:39:15 +0200 Subject: [PATCH 1/5] bpo-25655: Improve Win DLL loading failures doc https://bugs.python.org/issue25655 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. Signed-off-by: Philippe Ombredanne --- Doc/library/ctypes.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 2d6c6d0a1c3c57..6d8f0d2ac21cac 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1326,6 +1326,20 @@ 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 + :class:`OSError` error is raised with the message *"[WinError 126] The + specified module could not be found".* This error message does not contains + 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 missing, you need to find the list of missing + dependent DLLs using Windows debugging and tracing tools. + +.. seealso:: + + `MS 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) From be0b57d4f40e28e54d67811aca8c968ae23ed782 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Wed, 23 Sep 2020 10:55:13 +0200 Subject: [PATCH 2/5] bpo-25655: Use proper ReST <> brackets link syntax Signed-off-by: Philippe Ombredanne --- Doc/library/ctypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 6d8f0d2ac21cac..7909c118e8baa2 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1337,7 +1337,7 @@ way is to instantiate one of the following classes: .. seealso:: - `MS DUMPBIN tool https://docs.microsoft.com/cpp/build/reference/dependents`_ + `MS DUMPBIN tool `_ -- A tool to find DLL dependents. From 29a639f6d9fb7dd22d8a49dc26fe9201dec6b748 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Wed, 23 Sep 2020 15:05:51 +0200 Subject: [PATCH 3/5] bpo-25655: Use exc to reference an Exception in doc Exception references are made with exc and not class Signed-off-by: Philippe Ombredanne Co-authored-by: Dong-hee Na --- Doc/library/ctypes.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 7909c118e8baa2..fdb2592a5ea37d 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1328,7 +1328,7 @@ way is to instantiate one of the following classes: 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 - :class:`OSError` error is raised with the message *"[WinError 126] The + :exc:`OSError` error is raised with the message *"[WinError 126] The specified module could not be found".* This error message does not contains 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 @@ -2559,4 +2559,3 @@ Arrays and pointers Returns the object to which to pointer points. Assigning to this attribute changes the pointer to point to the assigned object. - From 55cbe3d7dad945ed3ed2a2778230db61b8d69768 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Wed, 23 Sep 2020 15:11:21 +0200 Subject: [PATCH 4/5] bpo-25655: Fix typo and clarify documentaion Signed-off-by: Philippe Ombredanne --- Doc/library/ctypes.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index fdb2592a5ea37d..d46cebea1929ba 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1329,11 +1329,12 @@ way is to instantiate one of the following classes: 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 contains + 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 missing, you need to find the list of missing - dependent DLLs using Windows debugging and tracing tools. + 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:: From 3b52591b1d4943d92b697356c02241b847a19011 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Tue, 20 Oct 2020 10:28:34 +0200 Subject: [PATCH 5/5] Update Doc/library/ctypes.rst Reported-by: Steve Dower Signed-off-by: Philippe Ombredanne Co-authored-by: Steve Dower --- Doc/library/ctypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index d46cebea1929ba..945d8e0bc332ce 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1338,7 +1338,7 @@ way is to instantiate one of the following classes: .. seealso:: - `MS DUMPBIN tool `_ + `Microsoft DUMPBIN tool `_ -- A tool to find DLL dependents.