diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-22 05:36:03 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-22 05:36:03 (GMT) |
commit | 462c357d70cf499f82349c6839c624e4f3026a49 (patch) | |
tree | 5603e559fd70655a77f7fc50a5bf5972525c5e9e /Lib/test/test_tcl.py | |
parent | 333518e01df0ce011962ca8629e766a59316e1cb (diff) | |
download | cpython-462c357d70cf499f82349c6839c624e4f3026a49.zip cpython-462c357d70cf499f82349c6839c624e4f3026a49.tar.gz cpython-462c357d70cf499f82349c6839c624e4f3026a49.tar.bz2 |
Fixed full Tcl version parsing in tests for pre-final versions.
Diffstat (limited to 'Lib/test/test_tcl.py')
-rw-r--r-- | Lib/test/test_tcl.py | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 38f37dd..9dae476 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -1,4 +1,5 @@ import unittest +import re import sys import os from test import support @@ -17,27 +18,22 @@ try: except ImportError: INT_MAX = PY_SSIZE_T_MAX = sys.maxsize -tcl_version = _tkinter.TCL_VERSION.split('.') -try: - for i in range(len(tcl_version)): - tcl_version[i] = int(tcl_version[i]) -except ValueError: - pass -tcl_version = tuple(tcl_version) +tcl_version = tuple(map(int, _tkinter.TCL_VERSION.split('.'))) _tk_patchlevel = None def get_tk_patchlevel(): global _tk_patchlevel if _tk_patchlevel is None: tcl = Tcl() - patchlevel = [] - for x in tcl.call('info', 'patchlevel').split('.'): - try: - x = int(x, 10) - except ValueError: - x = -1 - patchlevel.append(x) - _tk_patchlevel = tuple(patchlevel) + patchlevel = tcl.call('info', 'patchlevel') + m = re.fullmatch(r'(\d+)\.(\d+)([ab.])(\d+)', patchlevel) + major, minor, releaselevel, serial = m.groups() + major, minor, serial = int(major), int(minor), int(serial) + releaselevel = {'a': 'alpha', 'b': 'beta', '.': 'final'}[releaselevel] + if releaselevel == 'final': + _tk_patchlevel = major, minor, serial, releaselevel, 0 + else: + _tk_patchlevel = major, minor, 0, releaselevel, serial return _tk_patchlevel |