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
01121f2d
Commit
01121f2d
authored
Feb 27, 2012
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Plain Diff
Merged upstream changes.
parents
22fa0677
40e0f35a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
11 deletions
+25
-11
Lib/packaging/tests/test_version.py
Lib/packaging/tests/test_version.py
+9
-0
Lib/packaging/version.py
Lib/packaging/version.py
+13
-11
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/packaging/tests/test_version.py
View file @
01121f2d
...
...
@@ -16,6 +16,7 @@ class VersionTestCase(unittest.TestCase):
(
V
(
'1.2'
),
'1.2'
),
(
V
(
'1.2.3a4'
),
'1.2.3a4'
),
(
V
(
'1.2c4'
),
'1.2c4'
),
(
V
(
'4.17rc2'
),
'4.17rc2'
),
(
V
(
'1.2.3.4'
),
'1.2.3.4'
),
(
V
(
'1.2.3.4.0b3'
),
'1.2.3.4b3'
),
(
V
(
'1.2.0.0.0'
),
'1.2'
),
...
...
@@ -146,6 +147,14 @@ class VersionTestCase(unittest.TestCase):
"""
doctest
.
script_from_examples
(
comparison_doctest_string
)
# the doctest above is never run, so temporarily add real unit
# tests until the doctest is rewritten
self
.
assertLessEqual
(
V
(
'1.2.0rc1'
),
V
(
'1.2.0'
))
self
.
assertGreater
(
V
(
'1.0'
),
V
(
'1.0c2'
))
self
.
assertGreater
(
V
(
'1.0'
),
V
(
'1.0rc2'
))
self
.
assertGreater
(
V
(
'1.0rc2'
),
V
(
'1.0rc1'
))
self
.
assertGreater
(
V
(
'1.0c4'
),
V
(
'1.0c1'
))
def
test_suggest_normalized_version
(
self
):
self
.
assertEqual
(
suggest
(
'1.0'
),
'1.0'
)
...
...
Lib/packaging/version.py
View file @
01121f2d
...
...
@@ -11,19 +11,20 @@ __all__ = ['NormalizedVersion', 'suggest_normalized_version',
# A marker used in the second and third parts of the `parts` tuple, for
# versions that don't have those segments, to sort properly. An example
# of versions in sort order ('highest' last):
# 1.0b1 ((1,0), ('b',1), ('
f
',))
# 1.0.dev345 ((1,0), ('
f
',), ('dev', 345))
# 1.0 ((1,0), ('
f',), ('f
',))
# 1.0.post256.dev345 ((1,0), ('
f',), ('f
', 'post', 256, 'dev', 345))
# 1.0.post345 ((1,0), ('
f',), ('f', 'post', 345, 'f
'))
# 1.0b1 ((1,0), ('b',1), ('
z
',))
# 1.0.dev345 ((1,0), ('
z
',), ('dev', 345))
# 1.0 ((1,0), ('
z',), ('z
',))
# 1.0.post256.dev345 ((1,0), ('
z',), ('z
', 'post', 256, 'dev', 345))
# 1.0.post345 ((1,0), ('
z',), ('z', 'post', 345, 'z
'))
# ^ ^ ^
# 'b' < '
f
' ---------------------/ | |
# 'b' < '
z
' ---------------------/ | |
# | |
# 'dev' < '
f' < 'post'
-------------------/ |
# 'dev' < '
z' ---------
-------------------/ |
# |
# 'dev' < 'f' ----------------------------------------------/
# Other letters would do, but 'f' for 'final' is kind of nice.
_FINAL_MARKER
=
(
'f'
,)
# 'dev' < 'z' ----------------------------------------------/
# 'f' for 'final' would be kind of nice, but due to bugs in the support of
# 'rc' we must use 'z'
_FINAL_MARKER
=
(
'z'
,)
_VERSION_RE
=
re
.
compile
(
r'''
^
...
...
@@ -167,8 +168,9 @@ class NormalizedVersion:
if
prerel
is
not
_FINAL_MARKER
:
s
+=
prerel
[
0
]
s
+=
'.'
.
join
(
str
(
v
)
for
v
in
prerel
[
1
:])
# XXX clean up: postdev is always true; code is obscure
if
postdev
and
postdev
is
not
_FINAL_MARKER
:
if
postdev
[
0
]
==
'f'
:
if
postdev
[
0
]
==
_FINAL_MARKER
[
0
]
:
postdev
=
postdev
[
1
:]
i
=
0
while
i
<
len
(
postdev
):
...
...
Misc/NEWS
View file @
01121f2d
...
...
@@ -508,6 +508,9 @@ Core and Builtins
Library
-------
-
Issue
#
11841
:
Fix
comparison
bug
with
'rc'
versions
in
packaging
.
version
.
Patch
by
Filip
Gruszczy
ń
ski
.
-
Issue
#
13447
:
Add
a
test
file
to
host
regression
tests
for
bugs
in
the
scripts
found
in
the
Tools
directory
.
...
...
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