Skip to content

Commit 24fe460

Browse files
shireenraozooba
authored andcommitted
bpo-36266: Add module name in ImportError when DLL not found on Windows (pythonGH-15180)
1 parent 4558563 commit 24fe460

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

Python/dynload_win.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
240240
This should not happen if called correctly. */
241241
if (theLength == 0) {
242242
message = PyUnicode_FromFormat(
243-
"DLL load failed with error code %u",
244-
errorCode);
243+
"DLL load failed with error code %u while importing %s",
244+
errorCode, shortname);
245245
} else {
246246
/* For some reason a \r\n
247247
is appended to the text */
@@ -251,8 +251,8 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
251251
theLength -= 2;
252252
theInfo[theLength] = '\0';
253253
}
254-
message = PyUnicode_FromString(
255-
"DLL load failed: ");
254+
message = PyUnicode_FromFormat(
255+
"DLL load failed while importing %s: ", shortname);
256256

257257
PyUnicode_AppendAndDel(&message,
258258
PyUnicode_FromWideChar(

0 commit comments

Comments
 (0)