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
20a8392c
Unverified
Kaydet (Commit)
20a8392c
authored
Eyl 04, 2018
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Eyl 04, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[3.7] bpo-26544: Get rid of dependence from distutils in platform. (GH-8356). (GH-8970)
(cherry picked from commit
7d81e8f5
)
üst
7aa3eadc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
platform.py
Lib/platform.py
+30
-1
test_platform.py
Lib/test/test_platform.py
+36
-0
No files found.
Lib/platform.py
Dosyayı görüntüle @
20a8392c
...
...
@@ -136,6 +136,35 @@ except AttributeError:
# Constant used by test_platform to test linux_distribution().
_UNIXCONFDIR
=
'/etc'
# Helper for comparing two version number strings.
# Based on the description of the PHP's version_compare():
# http://php.net/manual/en/function.version-compare.php
_ver_stages
=
{
# any string not found in this dict, will get 0 assigned
'dev'
:
10
,
'alpha'
:
20
,
'a'
:
20
,
'beta'
:
30
,
'b'
:
30
,
'c'
:
40
,
'RC'
:
50
,
'rc'
:
50
,
# number, will get 100 assigned
'pl'
:
200
,
'p'
:
200
,
}
_component_re
=
re
.
compile
(
r'([0-9]+|[._+-])'
)
def
_comparable_version
(
version
):
result
=
[]
for
v
in
_component_re
.
split
(
version
):
if
v
not
in
'._+-'
:
try
:
v
=
int
(
v
,
10
)
t
=
100
except
ValueError
:
t
=
_ver_stages
.
get
(
v
,
0
)
result
.
extend
((
t
,
v
))
return
result
### Platform specific APIs
_libc_search
=
re
.
compile
(
b
'(__libc_init)'
...
...
@@ -159,7 +188,7 @@ def libc_ver(executable=sys.executable, lib='', version='', chunksize=16384):
The file is read and scanned in chunks of chunksize bytes.
"""
from
distutils.version
import
LooseVersion
as
V
V
=
_comparable_version
if
hasattr
(
os
.
path
,
'realpath'
):
# Python 2.2 introduced os.path.realpath(); it is used
# here to work around problems with Cygwin not being
...
...
Lib/test/test_platform.py
Dosyayı görüntüle @
20a8392c
...
...
@@ -285,6 +285,42 @@ class PlatformTest(unittest.TestCase):
self
.
assertEqual
(
platform
.
libc_ver
(
support
.
TESTFN
),
(
'glibc'
,
'1.23.4'
))
@support.cpython_only
def
test__comparable_version
(
self
):
from
platform
import
_comparable_version
as
V
self
.
assertEqual
(
V
(
'1.2.3'
),
V
(
'1.2.3'
))
self
.
assertLess
(
V
(
'1.2.3'
),
V
(
'1.2.10'
))
self
.
assertEqual
(
V
(
'1.2.3.4'
),
V
(
'1_2-3+4'
))
self
.
assertLess
(
V
(
'1.2spam'
),
V
(
'1.2dev'
))
self
.
assertLess
(
V
(
'1.2dev'
),
V
(
'1.2alpha'
))
self
.
assertLess
(
V
(
'1.2dev'
),
V
(
'1.2a'
))
self
.
assertLess
(
V
(
'1.2alpha'
),
V
(
'1.2beta'
))
self
.
assertLess
(
V
(
'1.2a'
),
V
(
'1.2b'
))
self
.
assertLess
(
V
(
'1.2beta'
),
V
(
'1.2c'
))
self
.
assertLess
(
V
(
'1.2b'
),
V
(
'1.2c'
))
self
.
assertLess
(
V
(
'1.2c'
),
V
(
'1.2RC'
))
self
.
assertLess
(
V
(
'1.2c'
),
V
(
'1.2rc'
))
self
.
assertLess
(
V
(
'1.2RC'
),
V
(
'1.2.0'
))
self
.
assertLess
(
V
(
'1.2rc'
),
V
(
'1.2.0'
))
self
.
assertLess
(
V
(
'1.2.0'
),
V
(
'1.2pl'
))
self
.
assertLess
(
V
(
'1.2.0'
),
V
(
'1.2p'
))
self
.
assertLess
(
V
(
'1.5.1'
),
V
(
'1.5.2b2'
))
self
.
assertLess
(
V
(
'3.10a'
),
V
(
'161'
))
self
.
assertEqual
(
V
(
'8.02'
),
V
(
'8.02'
))
self
.
assertLess
(
V
(
'3.4j'
),
V
(
'1996.07.12'
))
self
.
assertLess
(
V
(
'3.1.1.6'
),
V
(
'3.2.pl0'
))
self
.
assertLess
(
V
(
'2g6'
),
V
(
'11g'
))
self
.
assertLess
(
V
(
'0.9'
),
V
(
'2.2'
))
self
.
assertLess
(
V
(
'1.2'
),
V
(
'1.2.1'
))
self
.
assertLess
(
V
(
'1.1'
),
V
(
'1.2.2'
))
self
.
assertLess
(
V
(
'1.1'
),
V
(
'1.2'
))
self
.
assertLess
(
V
(
'1.2.1'
),
V
(
'1.2.2'
))
self
.
assertLess
(
V
(
'1.2'
),
V
(
'1.2.2'
))
self
.
assertLess
(
V
(
'0.4'
),
V
(
'0.4.0'
))
self
.
assertLess
(
V
(
'1.13++'
),
V
(
'5.5.kw'
))
self
.
assertLess
(
V
(
'0.960923'
),
V
(
'2.2beta29'
))
def
test_parse_release_file
(
self
):
for
input
,
output
in
(
...
...
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