[pypy-commit] pypy default: More fields for getwindowsversion (can't test, no windows).
alex_gaynor
noreply at buildbot.pypy.org
Sat Sep 10 07:59:51 CEST 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r47193:ca11f6ae93ae
Date: 2011-09-09 22:59 -0700
http://bitbucket.org/pypy/pypy/changeset/ca11f6ae93ae/
Log: More fields for getwindowsversion (can't test, no windows).
diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -378,6 +378,11 @@
assert v[3] == v.platform
assert v[4] == v.service_pack
+ assert isinstance(v.service_pack_minor, int)
+ assert isinstance(v.service_pack_major, int)
+ assert isinstance(v.suite_mask, int)
+ assert isinstance(v.product_type, int)
+
# This is how platform.py calls it. Make sure tuple still has 5
# elements
maj, min, buildno, plat, csd = sys.getwindowsversion()
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -162,8 +162,16 @@
build = structseqfield(2, "Build number")
platform = structseqfield(3, "Operating system platform")
service_pack = structseqfield(4, "Latest Service Pack installed on the system")
+
+ # Because the indices aren't consecutive, they aren't included when
+ # unpacking and other such operations.
+ service_pack_major = structseqfield(10, "Service Pack major version number")
+ service_pack_minor = structseqfield(11, "Service Pack minor version number")
+ suite_mask = structseqfield(12, "Bit mask identifying available product suites")
+ product_type = structseqfield(13, "System product type")
''')
+
def getwindowsversion(space):
from pypy.rlib import rwin32
info = rwin32.GetVersionEx()
@@ -173,7 +181,11 @@
space.wrap(info[1]),
space.wrap(info[2]),
space.wrap(info[3]),
- space.wrap(info[4])
+ space.wrap(info[4]),
+ space.wrap(info[5]),
+ space.wrap(info[6]),
+ space.wrap(info[7]),
+ space.wrap(info[8]),
])
return space.call_function(w_windows_version_info, raw_version)
diff --git a/pypy/rlib/rwin32.py b/pypy/rlib/rwin32.py
--- a/pypy/rlib/rwin32.py
+++ b/pypy/rlib/rwin32.py
@@ -55,14 +55,19 @@
SYSTEMTIME = rffi_platform.Struct('SYSTEMTIME',
[])
- OSVERSIONINFO = rffi_platform.Struct(
- 'OSVERSIONINFO',
+ OSVERSIONINFOEX = rffi_platform.Struct(
+ 'OSVERSIONINFOEX',
[('dwOSVersionInfoSize', rffi.UINT),
('dwMajorVersion', rffi.UINT),
('dwMinorVersion', rffi.UINT),
('dwBuildNumber', rffi.UINT),
('dwPlatformId', rffi.UINT),
- ('szCSDVersion', rffi.CFixedArray(lltype.Char, 1))])
+ ('szCSDVersion', rffi.CFixedArray(lltype.Char, 1)),
+ ('wServicePackMajor', rffi.USHORT),
+ ('wServicePackMinor', rffi.USHORT),
+ ('wSuiteMask', rffi.USHORT),
+ ('wProductType', rffi.UCHAR),
+ ])
LPSECURITY_ATTRIBUTES = rffi_platform.SimpleType(
"LPSECURITY_ATTRIBUTES", rffi.CCHARP)
@@ -225,14 +230,14 @@
lltype.free(buf, flavor='raw')
_GetVersionEx = winexternal('GetVersionExA',
- [lltype.Ptr(OSVERSIONINFO)],
+ [lltype.Ptr(OSVERSIONINFOEX)],
DWORD)
@jit.dont_look_inside
def GetVersionEx():
info = lltype.malloc(OSVERSIONINFO, flavor='raw')
rffi.setintfield(info, 'c_dwOSVersionInfoSize',
- rffi.sizeof(OSVERSIONINFO))
+ rffi.sizeof(OSVERSIONINFOEX))
try:
if not _GetVersionEx(info):
raise lastWindowsError()
@@ -241,7 +246,11 @@
rffi.cast(lltype.Signed, info.c_dwBuildNumber),
rffi.cast(lltype.Signed, info.c_dwPlatformId),
rffi.charp2str(rffi.cast(rffi.CCHARP,
- info.c_szCSDVersion)))
+ info.c_szCSDVersion)),
+ rffi.cast(lltype.Signed, info.c_wServicePackMajor),
+ rffi.cast(lltype.Signed, info.c_wServicePackMinor),
+ rffi.cast(lltype.Signed, info.c_wSuiteMask),
+ rffi.cast(lltype.Signed, info.c_wProductType))
finally:
lltype.free(info, flavor='raw')
More information about the pypy-commit
mailing list