diff options
author | Zackery Spytz <zspytz@gmail.com> | 2019-09-11 09:39:34 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@python.org> | 2019-09-11 09:39:34 (GMT) |
commit | 289c5ea7737e44e3b150532b3498e3d3d4c70d99 (patch) | |
tree | 5a4a64123fa06f5b2f7b0e1ae6ad548a95a74e8b | |
parent | 58d61efd4cdece3b026868a66d829001198d29b1 (diff) | |
download | cpython-289c5ea7737e44e3b150532b3498e3d3d4c70d99.zip cpython-289c5ea7737e44e3b150532b3498e3d3d4c70d99.tar.gz cpython-289c5ea7737e44e3b150532b3498e3d3d4c70d99.tar.bz2 |
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.rst | 2 | ||||
-rw-r--r-- | Modules/_ctypes/callproc.c | 4 | ||||
-rw-r--r-- | PC/bdist_wininst/install.c | 3 |
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 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 defcde1..066fefc 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 f1cc7fe..e3b52a8 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), |