cpython: 605fde022b15 (original) (raw)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -385,6 +385,9 @@ Tests Build ----- +- Issue #26624: Adds validation of ucrtbase[d].dll version with warning
- Issue #17603: Avoid error about nonexistant fileblocks.o file by using a lower-level check for st_blocks in struct stat.
--- a/PC/python_ver_rc.h +++ b/PC/python_ver_rc.h @@ -9,11 +9,10 @@ #define MS_WINDOWS #include "modsupport.h" #include "patchlevel.h" +#include <pythonnt_rc.h> #ifdef _DEBUG -# include <pythonnt_rc_d.h>
define PYTHON_DEBUG_EXT "_d"
#else -# include <pythonnt_rc.h>
define PYTHON_DEBUG_EXT
new file mode 100644 --- /dev/null +++ b/PC/validate_ucrtbase.py @@ -0,0 +1,88 @@ +''' +This script gets the version number from ucrtbased.dll and checks +whether it is a version with a known issue. +''' + +import sys + +from ctypes import (c_buffer, POINTER, byref, create_unicode_buffer,
Structure, WinDLL)[](#l3.13)
+from ctypes.wintypes import DWORD, HANDLE + +class VS_FIXEDFILEINFO(Structure):
- fields = [
("dwSignature", DWORD),[](#l3.18)
("dwStrucVersion", DWORD),[](#l3.19)
("dwFileVersionMS", DWORD),[](#l3.20)
("dwFileVersionLS", DWORD),[](#l3.21)
("dwProductVersionMS", DWORD),[](#l3.22)
("dwProductVersionLS", DWORD),[](#l3.23)
("dwFileFlagsMask", DWORD),[](#l3.24)
("dwFileFlags", DWORD),[](#l3.25)
("dwFileOS", DWORD),[](#l3.26)
("dwFileType", DWORD),[](#l3.27)
("dwFileSubtype", DWORD),[](#l3.28)
("dwFileDateMS", DWORD),[](#l3.29)
("dwFileDateLS", DWORD),[](#l3.30)
- ]
+ +kernel32 = WinDLL('kernel32') +version = WinDLL('version') + +if len(sys.argv) < 2:
- print('Cannot find ucrtbased.dll')
This likely means that VS is not installed, but that is an
obvious enough problem if you're trying to produce a debug
build that we don't need to fail here.
- sys.exit(0)
+ +# We will immediately double the length up to MAX_PATH, but the +# path may be longer, so we retry until the returned string is +# shorter than our buffer. +name_len = actual_len = 130 +while actual_len == name_len:
- name_len *= 2
- name = create_unicode_buffer(name_len)
- actual_len = kernel32.GetModuleFileNameW(HANDLE(ucrtbased._handle),
name, len(name))[](#l3.57)
- if not actual_len:
print('Failed to get full module name.')[](#l3.59)
sys.exit(2)[](#l3.60)
+ +size = version.GetFileVersionInfoSizeW(name, None) +if not size:
+ +ver_block = c_buffer(size) +if (not version.GetFileVersionInfoW(name, None, size, ver_block) or
+ +pvi = POINTER(VS_FIXEDFILEINFO)() +if not version.VerQueryValueW(ver_block, "", byref(pvi), byref(DWORD())):
- pvi.contents.dwProductVersionMS >> 16,
- pvi.contents.dwProductVersionMS & 0xFFFF,
- pvi.contents.dwProductVersionLS >> 16,
- pvi.contents.dwProductVersionLS & 0xFFFF,
+) + +print('{} is version {}.{}.{}.{}'.format(name.value, *ver)) + +if ver < (10, 0, 10586):
- print('WARN: ucrtbased contains known issues. '
'Please update Visual Studio or the Windows SDK.')[](#l3.89)
- print('See:')
- print(' http://bugs.python.org/issue26624')[](#l3.91)
- sys.exit(1)
--- a/PCbuild/python.vcxproj +++ b/PCbuild/python.vcxproj @@ -83,6 +83,13 @@