summaryrefslogtreecommitdiff
path: root/Python/dynload_win.c
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-01-04 02:04:15 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-01-04 02:04:15 +0000
commite0b76952860808cd60d627882b564453f46c970c (patch)
treed2c7f61794eb5f69d2cbbdbcb0818390ded6b203 /Python/dynload_win.c
parentd0d7d87869fb105ec3f849460d2c1b7f9fa851ec (diff)
downloadcpython-git-e0b76952860808cd60d627882b564453f46c970c.tar.gz
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.
Diffstat (limited to 'Python/dynload_win.c')
-rw-r--r--Python/dynload_win.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index fc641b9ff9..98ebccb2de 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -194,7 +194,8 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
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 */