summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-09 09:56:03 (GMT)
committerGitHub <noreply@github.com>2019-09-09 09:56:03 (GMT)
commit1af2c0ec2f63cc6516eb814c3e29d94451a52194 (patch)
tree26a808ef4f1f052cccc66931ffbc01e4281f4fcf
parent5190b7193c184268d5c8a9440b3a5a8bcd84a23e (diff)
downloadcpython-1af2c0ec2f63cc6516eb814c3e29d94451a52194.zip
cpython-1af2c0ec2f63cc6516eb814c3e29d94451a52194.tar.gz
cpython-1af2c0ec2f63cc6516eb814c3e29d94451a52194.tar.bz2
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 a6563650c835d50f7302971a5b145e94f9d0dc68) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
-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--Modules/overlapped.c3
-rw-r--r--PC/bdist_wininst/install.c3
4 files changed, 9 insertions, 3 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 0000000..e4805b4
--- /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 ec854c8..5861042 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -239,7 +239,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 */
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index 7798856..596ee33 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -486,7 +486,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),
diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c
index 04323eb..7a0e2e8 100644
--- a/PC/bdist_wininst/install.c
+++ b/PC/bdist_wininst/install.c
@@ -939,7 +939,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),