summaryrefslogtreecommitdiff
path: root/Lib/tkinter/test/support.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-22 08:36:03 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-22 08:36:03 +0300
commit462c357d70cf499f82349c6839c624e4f3026a49 (patch)
tree5603e559fd70655a77f7fc50a5bf5972525c5e9e /Lib/tkinter/test/support.py
parent333518e01df0ce011962ca8629e766a59316e1cb (diff)
downloadcpython-git-462c357d70cf499f82349c6839c624e4f3026a49.tar.gz
Fixed full Tcl version parsing in tests for pre-final versions.
Diffstat (limited to 'Lib/tkinter/test/support.py')
-rw-r--r--Lib/tkinter/test/support.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/tkinter/test/support.py b/Lib/tkinter/test/support.py
index 067fc71c8f..52df104003 100644
--- a/Lib/tkinter/test/support.py
+++ b/Lib/tkinter/test/support.py
@@ -1,7 +1,6 @@
-import sys
+import re
import tkinter
import unittest
-from test.support import requires
class AbstractTkTest:
@@ -63,14 +62,15 @@ def get_tk_patchlevel():
global _tk_patchlevel
if _tk_patchlevel is None:
tcl = tkinter.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
units = {