summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tcl.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-22 05:35:53 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-22 05:35:53 (GMT)
commitdcb12f46d10b357fd769cd157e2e9786ad7286cc (patch)
treef822dea2a787ee64eb6fbfad39f9382498156347 /Lib/test/test_tcl.py
parent656ffdb4de47e462eb4c94377a930511c245fd7b (diff)
downloadcpython-dcb12f46d10b357fd769cd157e2e9786ad7286cc.zip
cpython-dcb12f46d10b357fd769cd157e2e9786ad7286cc.tar.gz
cpython-dcb12f46d10b357fd769cd157e2e9786ad7286cc.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.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index 38a960c..81346f8 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 test_support
@@ -18,27 +19,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.match(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