summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-09-11 03:39:34 -0600
committerSteve Dower <steve.dower@python.org>2019-09-11 10:39:34 +0100
commit289c5ea7737e44e3b150532b3498e3d3d4c70d99 (patch)
tree5a4a64123fa06f5b2f7b0e1ae6ad548a95a74e8b
parent58d61efd4cdece3b026868a66d829001198d29b1 (diff)
downloadcpython-git-289c5ea7737e44e3b150532b3498e3d3d4c70d99.tar.gz
bpo-37445: Include FORMAT_MESSAGE_IGNORE_INSERTS in FormatMessageW() calls (GH-15822)
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)
-rw-r--r--Misc/NEWS.d/next/Windows/2019-06-28-18-10-29.bpo-37445.LsdYO6.rst2
-rw-r--r--Modules/_ctypes/callproc.c4
-rw-r--r--PC/bdist_wininst/install.c3
3 files changed, 7 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Windows/2019-06-28-18-10-29.bpo-37445.LsdYO6.rst b/Misc/NEWS.d/next/Windows/2019-06-28-18-10-29.bpo-37445.LsdYO6.rst
new file mode 100644
index 0000000000..e4805b4e02
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2019-06-28-18-10-29.bpo-37445.LsdYO6.rst
@@ -0,0 +1,2 @@
+Include the ``FORMAT_MESSAGE_IGNORE_INSERTS`` flag in ``FormatMessageW()``
+calls.
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index defcde1ff3..066fefc0cc 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -242,7 +242,9 @@ static TCHAR *FormatError(DWORD code)
{
TCHAR *lpMsgBuf;
DWORD n;
- n = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ n = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c
index f1cc7feed7..e3b52a8055 100644
--- a/PC/bdist_wininst/install.c
+++ b/PC/bdist_wininst/install.c
@@ -895,7 +895,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),