Skip to content

Commit 9151680

Browse files
bpo-46996: Remove support of Tcl/Tk < 8.5.12
1 parent af2277e commit 9151680

File tree

11 files changed

+92
-217
lines changed

11 files changed

+92
-217
lines changed

Doc/library/tkinter.ttk.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
--------------
1414

1515
The :mod:`tkinter.ttk` module provides access to the Tk themed widget set,
16-
introduced in Tk 8.5. If Python has not been compiled against Tk 8.5, this
17-
module can still be accessed if *Tile* has been installed. The former
18-
method using Tk 8.5 provides additional benefits including anti-aliased font
16+
introduced in Tk 8.5. It provides additional benefits including anti-aliased font
1917
rendering under X11 and window transparency (requiring a composition
2018
window manager on X11).
2119

Doc/whatsnew/3.11.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ Build Changes
703703
be removed at some point in the future. (Contributed by Mark Dickinson in
704704
:issue:`45569`.)
705705

706+
* The :mod:`tkinter` package now requires Tcl/Tk version 8.5.12 or newer.
707+
(Contributed by Serhiy Storchaka in :issue:`46996`.)
708+
706709

707710
C API Changes
708711
=============

Lib/test/test_tcl.py

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -144,26 +144,16 @@ def testUnsetVarException(self):
144144

145145
def get_integers(self):
146146
integers = (0, 1, -1, 2**31-1, -2**31, 2**31, -2**31-1, 2**63-1, -2**63)
147-
# bignum was added in Tcl 8.5, but its support is able only since 8.5.8.
148-
# Actually it is determined at compile time, so using get_tk_patchlevel()
149-
# is not reliable.
150-
# TODO: expose full static version.
151-
if tcl_version >= (8, 5):
152-
v = get_tk_patchlevel()
153-
if v >= (8, 6, 0, 'final') or (8, 5, 8) <= v < (8, 6):
154-
integers += (2**63, -2**63-1, 2**1000, -2**1000)
147+
integers += (2**63, -2**63-1, 2**1000, -2**1000)
155148
return integers
156149

157150
def test_getint(self):
158151
tcl = self.interp.tk
159152
for i in self.get_integers():
160153
self.assertEqual(tcl.getint(' %d ' % i), i)
161-
if tcl_version >= (8, 5):
162-
self.assertEqual(tcl.getint(' %#o ' % i), i)
154+
self.assertEqual(tcl.getint(' %#o ' % i), i)
163155
self.assertEqual(tcl.getint((' %#o ' % i).replace('o', '')), i)
164156
self.assertEqual(tcl.getint(' %#x ' % i), i)
165-
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
166-
self.assertRaises(TclError, tcl.getint, str(2**1000))
167157
self.assertEqual(tcl.getint(42), 42)
168158
self.assertRaises(TypeError, tcl.getint)
169159
self.assertRaises(TypeError, tcl.getint, '42', '10')
@@ -317,8 +307,7 @@ def check(expr, expected):
317307
check('"a\xbd\u20ac"', 'a\xbd\u20ac')
318308
check(r'"a\xbd\u20ac"', 'a\xbd\u20ac')
319309
check(r'"a\0b"', 'a\x00b')
320-
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
321-
check('2**64', str(2**64))
310+
check('2**64', str(2**64))
322311

323312
def test_exprdouble(self):
324313
tcl = self.interp
@@ -349,8 +338,7 @@ def check(expr, expected):
349338
check('[string length "a\xbd\u20ac"]', 3.0)
350339
check(r'[string length "a\xbd\u20ac"]', 3.0)
351340
self.assertRaises(TclError, tcl.exprdouble, '"abc"')
352-
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
353-
check('2**64', float(2**64))
341+
check('2**64', float(2**64))
354342

355343
def test_exprlong(self):
356344
tcl = self.interp
@@ -381,8 +369,7 @@ def check(expr, expected):
381369
check('[string length "a\xbd\u20ac"]', 3)
382370
check(r'[string length "a\xbd\u20ac"]', 3)
383371
self.assertRaises(TclError, tcl.exprlong, '"abc"')
384-
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
385-
self.assertRaises(TclError, tcl.exprlong, '2**64')
372+
self.assertRaises(TclError, tcl.exprlong, '2**64')
386373

387374
def test_exprboolean(self):
388375
tcl = self.interp
@@ -422,10 +409,8 @@ def check(expr, expected):
422409
check('[string length "a\xbd\u20ac"]', True)
423410
check(r'[string length "a\xbd\u20ac"]', True)
424411
self.assertRaises(TclError, tcl.exprboolean, '"abc"')
425-
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
426-
check('2**64', True)
412+
check('2**64', True)
427413

428-
@unittest.skipUnless(tcl_version >= (8, 5), 'requires Tcl version >= 8.5')
429414
def test_booleans(self):
430415
tcl = self.interp
431416
def check(expr, expected):
@@ -455,8 +440,6 @@ def test_expr_bignum(self):
455440
else:
456441
self.assertEqual(result, str(i))
457442
self.assertIsInstance(result, str)
458-
if get_tk_patchlevel() < (8, 5): # bignum was added in Tcl 8.5
459-
self.assertRaises(TclError, tcl.call, 'expr', str(2**1000))
460443

461444
def test_passing_values(self):
462445
def passValue(value):
@@ -485,8 +468,6 @@ def passValue(value):
485468
b'str\xbding' if self.wantobjects else 'str\xbding')
486469
for i in self.get_integers():
487470
self.assertEqual(passValue(i), i if self.wantobjects else str(i))
488-
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
489-
self.assertEqual(passValue(2**1000), str(2**1000))
490471
for f in (0.0, 1.0, -1.0, 1/3,
491472
sys.float_info.min, sys.float_info.max,
492473
-sys.float_info.min, -sys.float_info.max):
@@ -552,8 +533,6 @@ def float_eq(actual, expected):
552533
check(b'str\xc0\x80ing\xe2\x82\xac', 'str\xc0\x80ing\xe2\x82\xac')
553534
for i in self.get_integers():
554535
check(i, str(i))
555-
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
556-
check(2**1000, str(2**1000))
557536
for f in (0.0, 1.0, -1.0):
558537
check(f, repr(f))
559538
for f in (1/3.0, sys.float_info.min, sys.float_info.max,
@@ -600,16 +579,14 @@ def test_splitlist(self):
600579
('1', '2', '3.4')),
601580
]
602581
tk_patchlevel = get_tk_patchlevel()
603-
if tcl_version >= (8, 5):
604-
if not self.wantobjects or tk_patchlevel < (8, 5, 5):
605-
# Before 8.5.5 dicts were converted to lists through string
606-
expected = ('12', '\u20ac', '\xe2\x82\xac', '3.4')
607-
else:
608-
expected = (12, '\u20ac', b'\xe2\x82\xac', (3.4,))
609-
testcases += [
610-
(call('dict', 'create', 12, '\u20ac', b'\xe2\x82\xac', (3.4,)),
611-
expected),
612-
]
582+
if not self.wantobjects:
583+
expected = ('12', '\u20ac', '\xe2\x82\xac', '3.4')
584+
else:
585+
expected = (12, '\u20ac', b'\xe2\x82\xac', (3.4,))
586+
testcases += [
587+
(call('dict', 'create', 12, '\u20ac', b'\xe2\x82\xac', (3.4,)),
588+
expected),
589+
]
613590
dbg_info = ('want objects? %s, Tcl version: %s, Tk patchlevel: %s'
614591
% (self.wantobjects, tcl_version, tk_patchlevel))
615592
for arg, res in testcases:
@@ -642,15 +619,13 @@ def test_splitdict(self):
642619
{'a': (1, 2, 3) if self.wantobjects else '1 2 3',
643620
'something': 'foo', 'status': ''})
644621

645-
if tcl_version >= (8, 5):
646-
arg = tcl.call('dict', 'create',
647-
'-a', (1, 2, 3), '-something', 'foo', 'status', ())
648-
if not self.wantobjects or get_tk_patchlevel() < (8, 5, 5):
649-
# Before 8.5.5 dicts were converted to lists through string
650-
expected = {'a': '1 2 3', 'something': 'foo', 'status': ''}
651-
else:
652-
expected = {'a': (1, 2, 3), 'something': 'foo', 'status': ''}
653-
self.assertEqual(splitdict(tcl, arg), expected)
622+
arg = tcl.call('dict', 'create',
623+
'-a', (1, 2, 3), '-something', 'foo', 'status', ())
624+
if not self.wantobjects:
625+
expected = {'a': '1 2 3', 'something': 'foo', 'status': ''}
626+
else:
627+
expected = {'a': (1, 2, 3), 'something': 'foo', 'status': ''}
628+
self.assertEqual(splitdict(tcl, arg), expected)
654629

655630
def test_join(self):
656631
join = tkinter._join

Lib/tkinter/test/test_tkinter/test_geometry_managers.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from tkinter import TclError
55
from test.support import requires
66

7-
from tkinter.test.support import pixels_conv, tcl_version, requires_tcl
7+
from tkinter.test.support import pixels_conv
88
from tkinter.test.widget_tests import AbstractWidgetTest
99

1010
requires('gui')
@@ -295,8 +295,7 @@ def test_place_configure_in(self):
295295
with self.assertRaisesRegex(TclError, "can't place %s relative to "
296296
"itself" % re.escape(str(f2))):
297297
f2.place_configure(in_=f2)
298-
if tcl_version >= (8, 5):
299-
self.assertEqual(f2.winfo_manager(), '')
298+
self.assertEqual(f2.winfo_manager(), '')
300299
with self.assertRaisesRegex(TclError, 'bad window path name'):
301300
f2.place_configure(in_='spam')
302301
f2.place_configure(in_=f)
@@ -491,8 +490,7 @@ def tearDown(self):
491490
for i in range(rows + 1):
492491
self.root.grid_rowconfigure(i, weight=0, minsize=0, pad=0, uniform='')
493492
self.root.grid_propagate(1)
494-
if tcl_version >= (8, 5):
495-
self.root.grid_anchor('nw')
493+
self.root.grid_anchor('nw')
496494
super().tearDown()
497495

498496
def test_grid_configure(self):
@@ -619,16 +617,14 @@ def test_grid_columnconfigure(self):
619617
self.root.grid_columnconfigure((0, 3))
620618
b = tkinter.Button(self.root)
621619
b.grid_configure(column=0, row=0)
622-
if tcl_version >= (8, 5):
623-
self.root.grid_columnconfigure('all', weight=3)
624-
with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
625-
self.root.grid_columnconfigure('all')
626-
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3)
620+
self.root.grid_columnconfigure('all', weight=3)
621+
with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
622+
self.root.grid_columnconfigure('all')
623+
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3)
627624
self.assertEqual(self.root.grid_columnconfigure(3, 'weight'), 2)
628625
self.assertEqual(self.root.grid_columnconfigure(265, 'weight'), 0)
629-
if tcl_version >= (8, 5):
630-
self.root.grid_columnconfigure(b, weight=4)
631-
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4)
626+
self.root.grid_columnconfigure(b, weight=4)
627+
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4)
632628

633629
def test_grid_columnconfigure_minsize(self):
634630
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
@@ -675,16 +671,14 @@ def test_grid_rowconfigure(self):
675671
self.root.grid_rowconfigure((0, 3))
676672
b = tkinter.Button(self.root)
677673
b.grid_configure(column=0, row=0)
678-
if tcl_version >= (8, 5):
679-
self.root.grid_rowconfigure('all', weight=3)
680-
with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
681-
self.root.grid_rowconfigure('all')
682-
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3)
674+
self.root.grid_rowconfigure('all', weight=3)
675+
with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
676+
self.root.grid_rowconfigure('all')
677+
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3)
683678
self.assertEqual(self.root.grid_rowconfigure(3, 'weight'), 2)
684679
self.assertEqual(self.root.grid_rowconfigure(265, 'weight'), 0)
685-
if tcl_version >= (8, 5):
686-
self.root.grid_rowconfigure(b, weight=4)
687-
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4)
680+
self.root.grid_rowconfigure(b, weight=4)
681+
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4)
688682

689683
def test_grid_rowconfigure_minsize(self):
690684
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
@@ -774,7 +768,6 @@ def test_grid_info(self):
774768
self.assertEqual(info['pady'], self._str(4))
775769
self.assertEqual(info['sticky'], 'ns')
776770

777-
@requires_tcl(8, 5)
778771
def test_grid_anchor(self):
779772
with self.assertRaisesRegex(TclError, 'bad anchor "x"'):
780773
self.root.grid_anchor('x')

0 commit comments

Comments
 (0)