Skip to content

Commit 1af2c0e

Browse files
bpo-37445: Include FORMAT_MESSAGE_IGNORE_INSERTS in FormatMessageW() 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. (cherry picked from commit a656365) Co-authored-by: Zackery Spytz <[email protected]>
1 parent 5190b71 commit 1af2c0e

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Include the ``FORMAT_MESSAGE_IGNORE_INSERTS`` flag in ``FormatMessageW()``
2+
calls.

Modules/_ctypes/callproc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ static WCHAR *FormatError(DWORD code)
239239
{
240240
WCHAR *lpMsgBuf;
241241
DWORD n;
242-
n = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
242+
n = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
243+
FORMAT_MESSAGE_FROM_SYSTEM |
244+
FORMAT_MESSAGE_IGNORE_INSERTS,
243245
NULL,
244246
code,
245247
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */

Modules/overlapped.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ overlapped_FormatMessage(PyObject *ignore, PyObject *args)
486486
return NULL;
487487

488488
n = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
489-
FORMAT_MESSAGE_FROM_SYSTEM,
489+
FORMAT_MESSAGE_FROM_SYSTEM |
490+
FORMAT_MESSAGE_IGNORE_INSERTS,
490491
NULL,
491492
code,
492493
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),

PC/bdist_wininst/install.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ static BOOL SystemError(int error, char *msg)
939939
LPVOID lpMsgBuf;
940940
FormatMessage(
941941
FORMAT_MESSAGE_ALLOCATE_BUFFER |
942-
FORMAT_MESSAGE_FROM_SYSTEM,
942+
FORMAT_MESSAGE_FROM_SYSTEM |
943+
FORMAT_MESSAGE_IGNORE_INSERTS,
943944
NULL,
944945
error,
945946
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),

0 commit comments

Comments
 (0)