Skip to content

Commit

Permalink
bpo-37445: Include FORMAT_MESSAGE_IGNORE_INSERTS in FormatMessageW() …
Browse files Browse the repository at this point in the history
…calls (GH-14462)

If FormatMessageW() is passed the FORMAT_MESSAGE_FROM_SYSTEM flag without FORMAT_MESSAGE_IGNORE_INSERTS, it will fail if there are insert sequences in the message definition.
  • Loading branch information
ZackerySpytz authored and zooba committed Sep 9, 2019
1 parent 7669cb8 commit a656365
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
@@ -0,0 +1,2 @@
Include the ``FORMAT_MESSAGE_IGNORE_INSERTS`` flag in ``FormatMessageW()``
calls.
4 changes: 3 additions & 1 deletion Modules/_ctypes/callproc.c
Expand Up @@ -242,7 +242,9 @@ static WCHAR *FormatError(DWORD code)
{
WCHAR *lpMsgBuf;
DWORD n;
n = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
n = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
Expand Down
3 changes: 2 additions & 1 deletion Modules/overlapped.c
Expand Up @@ -500,7 +500,8 @@ overlapped_FormatMessage(PyObject *ignore, PyObject *args)
return NULL;

n = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
Expand Down
3 changes: 2 additions & 1 deletion PC/bdist_wininst/install.c
Expand Up @@ -938,7 +938,8 @@ static BOOL SystemError(int error, char *msg)
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
Expand Down

0 comments on commit a656365

Please sign in to comment.