Skip to content

Commit

Permalink
bpo-36266: Add module name in ImportError when DLL not found on Windo…
Browse files Browse the repository at this point in the history
…ws (GH-15180)

(cherry picked from commit 24fe460)

Co-authored-by: shireenrao <shireenrao@gmail.com>
  • Loading branch information
miss-islington and shireenrao committed Aug 17, 2019
1 parent 7309cca commit 786a4e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
@@ -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.
8 changes: 4 additions & 4 deletions Python/dynload_win.c
Expand Up @@ -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 */
Expand All @@ -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(
Expand Down

1 comment on commit 786a4e1

@Phillip-M-Feldman
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me.

Please sign in to comment.