[New-bugs-announce] [issue41535] platform win32_ver produces incorrect value for release on Windows domain controllers

John McCrone report at bugs.python.org
Wed Aug 12 17:07:17 EDT 2020


New submission from John McCrone <john.v.mccrone at gmail.com>:

The method platform.win32_ver() produces the client version for the release rather than the server version on a Windows domain controller.

This is easy to recreate on 3.8.5. For example, on a Windows 2012 server running as a domain controller, the method produces the following:

>>> import platform
>>> platform.win32_ver()
('8', '6.2.9200', 'SP0', 'Multiprocessor Free')

The product type is 2:
>>> import sys
>>> sys.getwindowsversion().product_type
2

The correct value should not be '8' but rather '2012Server'. From looking at the source (platform.py), it appears that we determine if we are on a windows server by this check:

if getattr(winver, 'product_type', None) == 3

However, both types 2 (Domain Controller) and 3 (Non-Domain Controller Server) are server types (see the documentation for sys.getwindowsversion() https://docs.python.org/3/library/sys.html). Therefore, it seems likely to me that it should check if the value of product_type is either 2 or 3 instead of just 3.

----------
components: Windows
messages: 375285
nosy: jvm3487, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: platform win32_ver produces incorrect value for release on Windows domain controllers
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41535>
_______________________________________


More information about the New-bugs-announce mailing list