Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6a294a54
Kaydet (Commit)
6a294a54
authored
Eyl 10, 2016
tarafından
Steve Dower
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #27932: Fixes memory leak in platform.win32_ver()
üst
8dcc48ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
29 deletions
+35
-29
platform.py
Lib/platform.py
+33
-29
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/platform.py
Dosyayı görüntüle @
6a294a54
...
@@ -498,57 +498,61 @@ _WIN32_SERVER_RELEASES = {
...
@@ -498,57 +498,61 @@ _WIN32_SERVER_RELEASES = {
(
6
,
None
):
"post2012ServerR2"
,
(
6
,
None
):
"post2012ServerR2"
,
}
}
def
_get_real_winver
(
maj
,
min
,
build
):
if
sys
.
platform
==
'win32'
:
if
maj
<
6
or
(
maj
==
6
and
min
<
2
):
import
ctypes
return
maj
,
min
,
build
import
ctypes.wintypes
from
ctypes
import
(
c_buffer
,
POINTER
,
byref
,
create_unicode_buffer
,
Structure
,
WinDLL
)
from
ctypes.wintypes
import
DWORD
,
HANDLE
class
VS_FIXEDFILEINFO
(
Structure
):
class
VS_FIXEDFILEINFO
(
ctypes
.
Structure
):
_fields_
=
[
_fields_
=
[
(
"dwSignature"
,
DWORD
),
(
"dwSignature"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwStrucVersion"
,
DWORD
),
(
"dwStrucVersion"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileVersionMS"
,
DWORD
),
(
"dwFileVersionMS"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileVersionLS"
,
DWORD
),
(
"dwFileVersionLS"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwProductVersionMS"
,
DWORD
),
(
"dwProductVersionMS"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwProductVersionLS"
,
DWORD
),
(
"dwProductVersionLS"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileFlagsMask"
,
DWORD
),
(
"dwFileFlagsMask"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileFlags"
,
DWORD
),
(
"dwFileFlags"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileOS"
,
DWORD
),
(
"dwFileOS"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileType"
,
DWORD
),
(
"dwFileType"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileSubtype"
,
DWORD
),
(
"dwFileSubtype"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileDateMS"
,
DWORD
),
(
"dwFileDateMS"
,
ctypes
.
wintypes
.
DWORD
),
(
"dwFileDateLS"
,
DWORD
),
(
"dwFileDateLS"
,
ctypes
.
wintypes
.
DWORD
),
]
]
kernel32
=
WinDLL
(
'kernel32'
)
P_VS_FIXEDFILEINFO
=
ctypes
.
POINTER
(
VS_FIXEDFILEINFO
)
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
=
create_unicode_buffer
(
name_len
)
name
=
ctypes
.
create_unicode_buffer
(
name_len
)
actual_len
=
kernel32
.
GetModuleFileNameW
(
HANDLE
(
kernel32
.
_handle
),
actual_len
=
kernel32
.
GetModuleFileNameW
(
name
,
len
(
name
))
ctypes
.
wintypes
.
HANDLE
(
kernel32
.
_handle
),
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_buffer
(
size
)
ver_block
=
c
types
.
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
=
POINTER
(
VS_FIXEDFILEINFO
)()
pvi
=
P_VS_FIXEDFILEINFO
()
if
not
version
.
VerQueryValueW
(
ver_block
,
""
,
byref
(
pvi
),
byref
(
DWORD
())):
if
not
version
.
VerQueryValueW
(
ver_block
,
""
,
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
Dosyayı görüntüle @
6a294a54
...
@@ -65,6 +65,8 @@ Core and Builtins
...
@@ -65,6 +65,8 @@ Core and Builtins
Library
Library
-------
-------
-
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