Skip to content

bpo-46996: Remove support of Tcl/Tk < 8.5.12 #31839

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Doc/library/tkinter.ttk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
--------------

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

Expand Down
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,9 @@ Build Changes
be removed at some point in the future. (Contributed by Mark Dickinson in
:issue:`45569`.)

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


C API Changes
=============
Expand Down
72 changes: 24 additions & 48 deletions Lib/test/test_tcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,18 @@ def testUnsetVarException(self):
self.assertRaises(TclError,tcl.unsetvar,'a')

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

def test_getint(self):
tcl = self.interp.tk
for i in self.get_integers():
self.assertEqual(tcl.getint(' %d ' % i), i)
if tcl_version >= (8, 5):
self.assertEqual(tcl.getint(' %#o ' % i), i)
self.assertEqual(tcl.getint(' %#o ' % i), i)
self.assertEqual(tcl.getint((' %#o ' % i).replace('o', '')), i)
self.assertEqual(tcl.getint(' %#x ' % i), i)
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
self.assertRaises(TclError, tcl.getint, str(2**1000))
self.assertEqual(tcl.getint(42), 42)
self.assertRaises(TypeError, tcl.getint)
self.assertRaises(TypeError, tcl.getint, '42', '10')
Expand Down Expand Up @@ -317,8 +308,7 @@ def check(expr, expected):
check('"a\xbd\u20ac"', 'a\xbd\u20ac')
check(r'"a\xbd\u20ac"', 'a\xbd\u20ac')
check(r'"a\0b"', 'a\x00b')
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
check('2**64', str(2**64))
check('2**64', str(2**64))

def test_exprdouble(self):
tcl = self.interp
Expand Down Expand Up @@ -349,8 +339,7 @@ def check(expr, expected):
check('[string length "a\xbd\u20ac"]', 3.0)
check(r'[string length "a\xbd\u20ac"]', 3.0)
self.assertRaises(TclError, tcl.exprdouble, '"abc"')
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
check('2**64', float(2**64))
check('2**64', float(2**64))

def test_exprlong(self):
tcl = self.interp
Expand Down Expand Up @@ -381,8 +370,7 @@ def check(expr, expected):
check('[string length "a\xbd\u20ac"]', 3)
check(r'[string length "a\xbd\u20ac"]', 3)
self.assertRaises(TclError, tcl.exprlong, '"abc"')
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
self.assertRaises(TclError, tcl.exprlong, '2**64')
self.assertRaises(TclError, tcl.exprlong, '2**64')

def test_exprboolean(self):
tcl = self.interp
Expand Down Expand Up @@ -422,10 +410,8 @@ def check(expr, expected):
check('[string length "a\xbd\u20ac"]', True)
check(r'[string length "a\xbd\u20ac"]', True)
self.assertRaises(TclError, tcl.exprboolean, '"abc"')
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
check('2**64', True)
check('2**64', True)

@unittest.skipUnless(tcl_version >= (8, 5), 'requires Tcl version >= 8.5')
def test_booleans(self):
tcl = self.interp
def check(expr, expected):
Expand Down Expand Up @@ -455,8 +441,6 @@ def test_expr_bignum(self):
else:
self.assertEqual(result, str(i))
self.assertIsInstance(result, str)
if get_tk_patchlevel() < (8, 5): # bignum was added in Tcl 8.5
self.assertRaises(TclError, tcl.call, 'expr', str(2**1000))

def test_passing_values(self):
def passValue(value):
Expand Down Expand Up @@ -485,8 +469,6 @@ def passValue(value):
b'str\xbding' if self.wantobjects else 'str\xbding')
for i in self.get_integers():
self.assertEqual(passValue(i), i if self.wantobjects else str(i))
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
self.assertEqual(passValue(2**1000), str(2**1000))
for f in (0.0, 1.0, -1.0, 1/3,
sys.float_info.min, sys.float_info.max,
-sys.float_info.min, -sys.float_info.max):
Expand Down Expand Up @@ -552,8 +534,6 @@ def float_eq(actual, expected):
check(b'str\xc0\x80ing\xe2\x82\xac', 'str\xc0\x80ing\xe2\x82\xac')
for i in self.get_integers():
check(i, str(i))
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
check(2**1000, str(2**1000))
for f in (0.0, 1.0, -1.0):
check(f, repr(f))
for f in (1/3.0, sys.float_info.min, sys.float_info.max,
Expand Down Expand Up @@ -600,16 +580,14 @@ def test_splitlist(self):
('1', '2', '3.4')),
]
tk_patchlevel = get_tk_patchlevel()
if tcl_version >= (8, 5):
if not self.wantobjects or tk_patchlevel < (8, 5, 5):
# Before 8.5.5 dicts were converted to lists through string
expected = ('12', '\u20ac', '\xe2\x82\xac', '3.4')
else:
expected = (12, '\u20ac', b'\xe2\x82\xac', (3.4,))
testcases += [
(call('dict', 'create', 12, '\u20ac', b'\xe2\x82\xac', (3.4,)),
expected),
]
if not self.wantobjects:
expected = ('12', '\u20ac', '\xe2\x82\xac', '3.4')
else:
expected = (12, '\u20ac', b'\xe2\x82\xac', (3.4,))
testcases += [
(call('dict', 'create', 12, '\u20ac', b'\xe2\x82\xac', (3.4,)),
expected),
]
dbg_info = ('want objects? %s, Tcl version: %s, Tk patchlevel: %s'
% (self.wantobjects, tcl_version, tk_patchlevel))
for arg, res in testcases:
Expand Down Expand Up @@ -642,15 +620,13 @@ def test_splitdict(self):
{'a': (1, 2, 3) if self.wantobjects else '1 2 3',
'something': 'foo', 'status': ''})

if tcl_version >= (8, 5):
arg = tcl.call('dict', 'create',
'-a', (1, 2, 3), '-something', 'foo', 'status', ())
if not self.wantobjects or get_tk_patchlevel() < (8, 5, 5):
# Before 8.5.5 dicts were converted to lists through string
expected = {'a': '1 2 3', 'something': 'foo', 'status': ''}
else:
expected = {'a': (1, 2, 3), 'something': 'foo', 'status': ''}
self.assertEqual(splitdict(tcl, arg), expected)
arg = tcl.call('dict', 'create',
'-a', (1, 2, 3), '-something', 'foo', 'status', ())
if not self.wantobjects:
expected = {'a': '1 2 3', 'something': 'foo', 'status': ''}
else:
expected = {'a': (1, 2, 3), 'something': 'foo', 'status': ''}
self.assertEqual(splitdict(tcl, arg), expected)

def test_join(self):
join = tkinter._join
Expand Down
37 changes: 15 additions & 22 deletions Lib/tkinter/test/test_tkinter/test_geometry_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from tkinter import TclError
from test.support import requires

from tkinter.test.support import pixels_conv, tcl_version, requires_tcl
from tkinter.test.support import pixels_conv
from tkinter.test.widget_tests import AbstractWidgetTest

requires('gui')
Expand Down Expand Up @@ -295,8 +295,7 @@ def test_place_configure_in(self):
with self.assertRaisesRegex(TclError, "can't place %s relative to "
"itself" % re.escape(str(f2))):
f2.place_configure(in_=f2)
if tcl_version >= (8, 5):
self.assertEqual(f2.winfo_manager(), '')
self.assertEqual(f2.winfo_manager(), '')
with self.assertRaisesRegex(TclError, 'bad window path name'):
f2.place_configure(in_='spam')
f2.place_configure(in_=f)
Expand Down Expand Up @@ -491,8 +490,7 @@ def tearDown(self):
for i in range(rows + 1):
self.root.grid_rowconfigure(i, weight=0, minsize=0, pad=0, uniform='')
self.root.grid_propagate(1)
if tcl_version >= (8, 5):
self.root.grid_anchor('nw')
self.root.grid_anchor('nw')
super().tearDown()

def test_grid_configure(self):
Expand Down Expand Up @@ -619,16 +617,14 @@ def test_grid_columnconfigure(self):
self.root.grid_columnconfigure((0, 3))
b = tkinter.Button(self.root)
b.grid_configure(column=0, row=0)
if tcl_version >= (8, 5):
self.root.grid_columnconfigure('all', weight=3)
with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
self.root.grid_columnconfigure('all')
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3)
self.root.grid_columnconfigure('all', weight=3)
with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
self.root.grid_columnconfigure('all')
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3)
self.assertEqual(self.root.grid_columnconfigure(3, 'weight'), 2)
self.assertEqual(self.root.grid_columnconfigure(265, 'weight'), 0)
if tcl_version >= (8, 5):
self.root.grid_columnconfigure(b, weight=4)
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4)
self.root.grid_columnconfigure(b, weight=4)
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4)

def test_grid_columnconfigure_minsize(self):
with self.assertRaisesRegex(TclError, 'bad screen distance "foo"'):
Expand Down Expand Up @@ -675,16 +671,14 @@ def test_grid_rowconfigure(self):
self.root.grid_rowconfigure((0, 3))
b = tkinter.Button(self.root)
b.grid_configure(column=0, row=0)
if tcl_version >= (8, 5):
self.root.grid_rowconfigure('all', weight=3)
with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
self.root.grid_rowconfigure('all')
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3)
self.root.grid_rowconfigure('all', weight=3)
with self.assertRaisesRegex(TclError, 'expected integer but got "all"'):
self.root.grid_rowconfigure('all')
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3)
self.assertEqual(self.root.grid_rowconfigure(3, 'weight'), 2)
self.assertEqual(self.root.grid_rowconfigure(265, 'weight'), 0)
if tcl_version >= (8, 5):
self.root.grid_rowconfigure(b, weight=4)
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4)
self.root.grid_rowconfigure(b, weight=4)
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4)

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

@requires_tcl(8, 5)
def test_grid_anchor(self):
with self.assertRaisesRegex(TclError, 'bad anchor "x"'):
self.root.grid_anchor('x')
Expand Down
Loading