bpo-36266: Add module name in ImportError when DLL not found on Windows (GH-15180)
(cherry picked from commit 24fe46081be3d1c01b3d21cb39bc3492ab4485a3)
Co-authored-by: shireenrao <shireenrao@gmail.com>
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index 457d47f..2f28c3c 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -258,8 +258,8 @@
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 @@
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(