Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
81994006
Commit
81994006
authored
Sep 10, 2016
by
Steve Dower
Browse files
Options
Browse Files
Download
Plain Diff
Merge from 3.5
parents
473e0e4d
f028d9f7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
35 deletions
+29
-35
Lib/platform.py
Lib/platform.py
+29
-33
Misc/NEWS
Misc/NEWS
+0
-2
No files found.
Lib/platform.py
View file @
81994006
...
@@ -497,61 +497,57 @@ _WIN32_SERVER_RELEASES = {
...
@@ -497,61 +497,57 @@ _WIN32_SERVER_RELEASES = {
(6, None): "post2012ServerR2",
(6, None): "post2012ServerR2",
}
}
if sys.platform == '
win32
'
:
def _get_real_winver(maj, min, build)
:
i
mport ctypes
i
f maj < 6 or (maj == 6 and min < 2):
import ctypes.wintypes
return maj, min, build
class VS_FIXEDFILEINFO(ctypes.Structure):
from ctypes import (c_buffer, POINTER, byref, create_unicode_buffer,
Structure, WinDLL)
from ctypes.wintypes import DWORD, HANDLE
class VS_FIXEDFILEINFO(Structure):
_fields_ = [
_fields_ = [
("dwSignature",
ctypes.wintypes.
DWORD),
("dwSignature", DWORD),
("dwStrucVersion",
ctypes.wintypes.
DWORD),
("dwStrucVersion", DWORD),
("dwFileVersionMS",
ctypes.wintypes.
DWORD),
("dwFileVersionMS", DWORD),
("dwFileVersionLS",
ctypes.wintypes.
DWORD),
("dwFileVersionLS", DWORD),
("dwProductVersionMS",
ctypes.wintypes.
DWORD),
("dwProductVersionMS", DWORD),
("dwProductVersionLS",
ctypes.wintypes.
DWORD),
("dwProductVersionLS", DWORD),
("dwFileFlagsMask",
ctypes.wintypes.
DWORD),
("dwFileFlagsMask", DWORD),
("dwFileFlags",
ctypes.wintypes.
DWORD),
("dwFileFlags", DWORD),
("dwFileOS",
ctypes.wintypes.
DWORD),
("dwFileOS", DWORD),
("dwFileType",
ctypes.wintypes.
DWORD),
("dwFileType", DWORD),
("dwFileSubtype",
ctypes.wintypes.
DWORD),
("dwFileSubtype", DWORD),
("dwFileDateMS",
ctypes.wintypes.
DWORD),
("dwFileDateMS", DWORD),
("dwFileDateLS",
ctypes.wintypes.
DWORD),
("dwFileDateLS", DWORD),
]
]
P_VS_FIXEDFILEINFO = ctypes.POINTER(VS_FIXEDFILEINFO)
kernel32 = WinDLL('
kernel32
')
version = WinDLL('
version
')
def _get_real_winver(maj, min, build):
if maj < 6 or (maj == 6 and min < 2):
return maj, min, build
kernel32 = ctypes.WinDLL('
kernel32
')
# We will immediately double the length up to MAX_PATH, but the
# We will immediately double the length up to MAX_PATH, but the
# path may be longer, so we retry until the returned string is
# path may be longer, so we retry until the returned string is
# shorter than our buffer.
# shorter than our buffer.
name_len = actual_len = 130
name_len = actual_len = 130
while actual_len == name_len:
while actual_len == name_len:
name_len *= 2
name_len *= 2
name = ctypes.create_unicode_buffer(name_len)
name = create_unicode_buffer(name_len)
actual_len = kernel32.GetModuleFileNameW(
actual_len = kernel32.GetModuleFileNameW(HANDLE(kernel32._handle),
ctypes.wintypes.HANDLE(kernel32._handle),
name, len(name))
name, len(name)
)
if not actual_len:
if not actual_len:
return maj, min, build
return maj, min, build
version = ctypes.WinDLL('
version
')
size = version.GetFileVersionInfoSizeW(name, None)
size = version.GetFileVersionInfoSizeW(name, None)
if not size:
if not size:
return maj, min, build
return maj, min, build
ver_block = c
types.c
_buffer(size)
ver_block = c_buffer(size)
if (not version.GetFileVersionInfoW(name, None, size, ver_block) or
if (not version.GetFileVersionInfoW(name, None, size, ver_block) or
not ver_block):
not ver_block):
return maj, min, build
return maj, min, build
pvi = P_VS_FIXEDFILEINFO()
pvi = POINTER(VS_FIXEDFILEINFO)()
if not version.VerQueryValueW(ver_block, "",
if not version.VerQueryValueW(ver_block, "", byref(pvi), byref(DWORD())):
ctypes.byref(pvi), ctypes.byref(ctypes.wintypes.DWORD())):
return maj, min, build
return maj, min, build
maj = pvi.contents.dwProductVersionMS >> 16
maj = pvi.contents.dwProductVersionMS >> 16
...
...
Misc/NEWS
View file @
81994006
...
@@ -156,8 +156,6 @@ Library
...
@@ -156,8 +156,6 @@ Library
- Issue #25969: Update the lib2to3 grammar to handle the unpacking
- Issue #25969: Update the lib2to3 grammar to handle the unpacking
generalizations added in 3.5.
generalizations added in 3.5.
- Issue #27932: Fixes memory leak in platform.win32_ver()
- Issue #14977: mailcap now respects the order of the lines in the mailcap
- Issue #14977: mailcap now respects the order of the lines in the mailcap
files ("first match"), as required by RFC 1542. Patch by Michael Lazar.
files ("first match"), as required by RFC 1542. Patch by Michael Lazar.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment