version parsing: fix errors with 3.0.0_pre1 (!1735)
Python < 3.6 randomized the order of keys in dictionaries, unless OrderedDict was used. Use OrderedDict to store the version suffixes. When the order was randomized, the valid version string 3.0.0_pre1 did not always pass the validation check. The suffix "pre" should always be detected as such, but with the random order, it was sometimes detected as "p" suffix (see below). The following letters "re" are not a valid suffix_no (the number expected to follow the suffix) and so it failed. suffixes = { "pre": ["pre", ...], "post": ["p". ...] }
This commit is contained in:
parent
101a396c90
commit
7f956e2f72
|
@ -16,6 +16,7 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
import collections
|
||||||
|
|
||||||
"""
|
"""
|
||||||
In order to stay as compatible to Alpine's apk as possible, this code
|
In order to stay as compatible to Alpine's apk as possible, this code
|
||||||
|
@ -122,10 +123,11 @@ def parse_suffix(rest):
|
||||||
|
|
||||||
C equivalent: get_token(), case TOKEN_SUFFIX
|
C equivalent: get_token(), case TOKEN_SUFFIX
|
||||||
"""
|
"""
|
||||||
suffixes = {
|
|
||||||
"pre": ["alpha", "beta", "pre", "rc"],
|
suffixes = collections.OrderedDict([
|
||||||
"post": ["cvs", "svn", "git", "hg", "p"]
|
("pre", ["alpha", "beta", "pre", "rc"]),
|
||||||
}
|
("post", ["cvs", "svn", "git", "hg", "p"]),
|
||||||
|
])
|
||||||
|
|
||||||
for name, suffixes in suffixes.items():
|
for name, suffixes in suffixes.items():
|
||||||
for i, suffix in enumerate(suffixes):
|
for i, suffix in enumerate(suffixes):
|
||||||
|
|
Loading…
Reference in New Issue