| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a07da09 commit 2a3f489
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -796,11 +796,16 @@ always available. | |||
| 796 | 796 | Microsoft documentation on :c:func:`OSVERSIONINFOEX` for more information | |
| 797 | 797 | about these fields. | |
| 798 | 798 | ||
| 799 | - *platform_version* returns the accurate major version, minor version and | ||
| 799 | + *platform_version* returns the major version, minor version and | ||
| 800 | 800 | build number of the current operating system, rather than the version that | |
| 801 | 801 | is being emulated for the process. It is intended for use in logging rather | |
| 802 | 802 | than for feature detection. | |
| 803 | 803 | ||
| 804 | + .. note:: | ||
| 805 | + *platform_version* derives the version from kernel32.dll which can be of a different | ||
| 806 | + version than the OS version. Please use :mod:`platform` module for achieving accurate | ||
| 807 | + OS version. | ||
| 808 | + | ||
| 804 | 809 | .. availability:: Windows. | |
| 805 | 810 | ||
| 806 | 811 | .. versionchanged:: 3.2 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -239,11 +239,9 @@ def _norm_version(version, build=''): | |||
| 239 | 239 | if build: | |
| 240 | 240 | l.append(build) | |
| 241 | 241 | try: | |
| 242 | - ints = map(int, l) | ||
| 242 | + strings = list(map(str, map(int, l))) | ||
| 243 | 243 | except ValueError: | |
| 244 | 244 | strings = l | |
| 245 | - else: | ||
| 246 | - strings = list(map(str, ints)) | ||
| 247 | 245 | version = '.'.join(strings[:3]) | |
| 248 | 246 | return version | |
| 249 | 247 | ||
@@ -365,17 +363,20 @@ def win32_ver(release='', version='', csd='', ptype=''): | |||
| 365 | 363 | return release, version, csd, ptype | |
| 366 | 364 | ||
| 367 | 365 | winver = getwindowsversion() | |
| 368 | - maj, min, build = winver.platform_version or winver[:3] | ||
| 369 | - version = '{0}.{1}.{2}'.format(maj, min, build) | ||
| 366 | + try: | ||
| 367 | + major, minor, build = map(int, _syscmd_ver()[2].split('.')) | ||
| 368 | + except ValueError: | ||
| 369 | + major, minor, build = winver.platform_version or winver[:3] | ||
| 370 | + version = '{0}.{1}.{2}'.format(major, minor, build) | ||
| 370 | 371 | ||
| 371 | - release = (_WIN32_CLIENT_RELEASES.get((maj, min)) or | ||
| 372 | - _WIN32_CLIENT_RELEASES.get((maj, None)) or | ||
| 372 | + release = (_WIN32_CLIENT_RELEASES.get((major, minor)) or | ||
| 373 | + _WIN32_CLIENT_RELEASES.get((major, None)) or | ||
| 373 | 374 | release) | |
| 374 | 375 | ||
| 375 | 376 | # getwindowsversion() reflect the compatibility mode Python is | |
| 376 | 377 | # running under, and so the service pack value is only going to be | |
| 377 | 378 | # valid if the versions match. | |
| 378 | - if winver[:2] == (maj, min): | ||
| 379 | + if winver[:2] == (major, minor): | ||
| 379 | 380 | try: | |
| 380 | 381 | csd = 'SP{}'.format(winver.service_pack_major) | |
| 381 | 382 | except AttributeError: | |
@@ -384,8 +385,8 @@ def win32_ver(release='', version='', csd='', ptype=''): | |||
| 384 | 385 | ||
| 385 | 386 | # VER_NT_SERVER = 3 | |
| 386 | 387 | if getattr(winver, 'product_type', None) == 3: | |
| 387 | - release = (_WIN32_SERVER_RELEASES.get((maj, min)) or | ||
| 388 | - _WIN32_SERVER_RELEASES.get((maj, None)) or | ||
| 388 | + release = (_WIN32_SERVER_RELEASES.get((major, minor)) or | ||
| 389 | + _WIN32_SERVER_RELEASES.get((major, None)) or | ||
| 389 | 390 | release) | |
| 390 | 391 | ||
| 391 | 392 | try: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,6 @@ | |||
| 1 | + platform.win32_ver derives the windows version from | ||
| 2 | + sys.getwindowsversion().platform_version which in turn derives the version | ||
| 3 | + from kernel32.dll (which can be of a different version than Windows itself). | ||
| 4 | + Therefore change the platform.win32_ver to determine the version using the | ||
| 5 | + platform module's _syscmd_ver private function to return an accurate | ||
| 6 | + version. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments