]> granicus.if.org Git - python/commitdiff
bpo-36266: Add module name in ImportError when DLL not found on Windows (GH-15180)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 17 Aug 2019 21:11:28 +0000 (14:11 -0700)
committerGitHub <noreply@github.com>
Sat, 17 Aug 2019 21:11:28 +0000 (14:11 -0700)
(cherry picked from commit 24fe46081be3d1c01b3d21cb39bc3492ab4485a3)

Co-authored-by: shireenrao <shireenrao@gmail.com>
Misc/NEWS.d/next/Windows/2019-08-08-18-05-27.bpo-36266.x4eZU3.rst [new file with mode: 0644]
Python/dynload_win.c

diff --git a/Misc/NEWS.d/next/Windows/2019-08-08-18-05-27.bpo-36266.x4eZU3.rst b/Misc/NEWS.d/next/Windows/2019-08-08-18-05-27.bpo-36266.x4eZU3.rst
new file mode 100644 (file)
index 0000000..86fdd6f
--- /dev/null
@@ -0,0 +1 @@
+Add the module name in the formatted error message when DLL load fail happens during module import in ``_PyImport_FindSharedFuncptrWindows()``. Patch by Srinivas Nyayapati.
\ No newline at end of file
index 457d47f5eed50a8f658e9ed5627584d61f5b94cd..2f28c3cf924957bf2668dcd1449c68bbe9e5eed3 100644 (file)
@@ -258,8 +258,8 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
                This should not happen if called correctly. */
             if (theLength == 0) {
                 message = PyUnicode_FromFormat(
-                    "DLL load failed with error code %u",
-                    errorCode);
+                    "DLL load failed with error code %u while importing %s",
+                    errorCode, shortname);
             } else {
                 /* For some reason a \r\n
                    is appended to the text */
@@ -269,8 +269,8 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
                     theLength -= 2;
                     theInfo[theLength] = '\0';
                 }
-                message = PyUnicode_FromString(
-                    "DLL load failed: ");
+                message = PyUnicode_FromFormat(
+                    "DLL load failed while importing %s: ", shortname);
 
                 PyUnicode_AppendAndDel(&message,
                     PyUnicode_FromWideChar(