@@ -738,11 +738,7 @@ def parse_version(version, strict = False):
738738
739739 parser = _new (version .strip (" " if strict else " .*" )) # PEP 440: Leading and Trailing Whitespace and .*
740740
741- # TODO @aignas 2025-05-06: Remove this usage of a second parser just to get the normalized
742- # version.
743- parser_2 = _new (version .strip (" " if strict else " .*" )) # PEP 440: Leading and Trailing Whitespace and .*
744741 accept (parser , _is ("v" ), "" ) # PEP 440: Preceding v character
745- accept (parser_2 , _is ("v" ), "" ) # PEP 440: Preceding v character
746742
747743 parts = {}
748744 fns = [
@@ -756,7 +752,6 @@ def parse_version(version, strict = False):
756752
757753 for p , fn in fns :
758754 fn (parser )
759- fn (parser_2 )
760755 parts [p ] = parser .context ()["norm" ]
761756 parser .context ()["norm" ] = "" # Clear out the buffer so that it is easy to separate the fields
762757
@@ -769,7 +764,7 @@ def parse_version(version, strict = False):
769764 # https://peps.python.org/pep-0440/#public-version-identifiers
770765 return None
771766
772- if parser_2 .input [parser .context ()["start" ]:]:
767+ if parser .input [parser .context ()["start" ]:]:
773768 if strict :
774769 fail (
775770 "Failed to parse PEP 440 version identifier '%s'." % parser .input ,
@@ -779,5 +774,5 @@ def parse_version(version, strict = False):
779774 # If we fail to parse the version return None
780775 return None
781776
782- parts ["norm" ] = parser_2 . context ()[ "norm" ]
777+ parts ["norm" ] = "" . join ([ parts [ p ] for p , _ in fns ])
783778 return _new_version (** parts )
0 commit comments