diff Python/dynload_win.c @ 44455:de00af03bb4d legacy-trunk

Partial port of r59682 from py3k. On Windows, when import fails to load a dll module, the message says "error code 193" instead of a more informative text. It turns out that FormatMessage needs additional parameters for some error codes. For example: 193 means "%1 is not a valid Win32 application". Since it is impossible to know which parameter to pass, we use FORMAT_MESSAGE_IGNORE_INSERTS to get the raw message, which is still better than the number.
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Fri, 04 Jan 2008 02:04:15 +0000
parents 9d02a4adf574
children 76a89dd4a512
line wrap: on
line diff
--- a/Python/dynload_win.c	Fri Jan 04 02:03:25 2008 +0000
+++ b/Python/dynload_win.c	Fri Jan 04 02:04:15 2008 +0000
@@ -194,7 +194,8 @@
 			errorCode = GetLastError();
 
 			theLength = FormatMessage(
-				FORMAT_MESSAGE_FROM_SYSTEM, /* flags */
+				FORMAT_MESSAGE_FROM_SYSTEM |
+				FORMAT_MESSAGE_IGNORE_INSERTS, /* flags */
 				NULL, /* message source */
 				errorCode, /* the message (error) ID */
 				0, /* default language environment */