From 04cfd2a97d04d23579684f770854f3a4c2da8915 Mon Sep 17 00:00:00 2001 From: Srinivas Nyayapati Date: Thu, 8 Aug 2019 13:42:19 -0400 Subject: [PATCH 1/4] Add module name in ImportError when DLL not found on Windows --- Python/dynload_win.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 5096555e701c49..cb0b0710a851a8 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -240,8 +240,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); + "While importing %s, DLL load failed with error code %u", + shortname, errorCode); } else { /* For some reason a \r\n is appended to the text */ @@ -251,8 +251,8 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, theLength -= 2; theInfo[theLength] = '\0'; } - message = PyUnicode_FromString( - "DLL load failed: "); + message = PyUnicode_FromFormat( + "While importing %s, DLL load failed: ", shortname); PyUnicode_AppendAndDel(&message, PyUnicode_FromWideChar( From 11fa5ebc1310c6035f5b69ea9967239e85a3f893 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2019 18:05:29 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Windows/2019-08-08-18-05-27.bpo-36266.x4eZU3.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Windows/2019-08-08-18-05-27.bpo-36266.x4eZU3.rst 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 index 00000000000000..3ac71b9978699b --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2019-08-08-18-05-27.bpo-36266.x4eZU3.rst @@ -0,0 +1 @@ +Add the module name in the formatted error message when DLL load fail happens during module import in :c:func:`_PyImport_FindSharedFuncptrWindows()`. Patch by Srinivas Nyayapati. \ No newline at end of file From e97eaf5712b59e5455f6d7bcc66dc95a428895ce Mon Sep 17 00:00:00 2001 From: Srinivas Nyayapati Date: Tue, 13 Aug 2019 14:14:37 -0400 Subject: [PATCH 3/4] Update error message based on review --- Python/dynload_win.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/dynload_win.c b/Python/dynload_win.c index cb0b0710a851a8..6deba1134e2a4b 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -240,8 +240,8 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, This should not happen if called correctly. */ if (theLength == 0) { message = PyUnicode_FromFormat( - "While importing %s, DLL load failed with error code %u", - shortname, 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 */ @@ -252,7 +252,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, theInfo[theLength] = '\0'; } message = PyUnicode_FromFormat( - "While importing %s, DLL load failed: ", shortname); + "DLL load failed while importing %s: ", shortname); PyUnicode_AppendAndDel(&message, PyUnicode_FromWideChar( From 93912acd5b91d92fad12a991c0e6e753a894385f Mon Sep 17 00:00:00 2001 From: Srinivas Nyayapati Date: Thu, 15 Aug 2019 08:06:50 -0400 Subject: [PATCH 4/4] remove c:func from NEWS message --- .../next/Windows/2019-08-08-18-05-27.bpo-36266.x4eZU3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 3ac71b9978699b..86fdd6fe17f416 100644 --- 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 @@ -1 +1 @@ -Add the module name in the formatted error message when DLL load fail happens during module import in :c:func:`_PyImport_FindSharedFuncptrWindows()`. Patch by Srinivas Nyayapati. \ No newline at end of file +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