Issue #22226: Added private function _splitdict() in the Tkinter module.
First letter no longer is stripped from the "status" key in
the result of Treeview.heading().
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index c0afba6..d627034 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -7,6 +7,9 @@
# Skip this test if the _tkinter module wasn't built.
_tkinter = test_support.import_module('_tkinter')
+# Make sure tkinter._fix runs to set up the environment
+tkinter = test_support.import_fresh_module('Tkinter')
+
from Tkinter import Tcl
from _tkinter import TclError
@@ -565,6 +568,42 @@
for arg, res in testcases:
self.assertEqual(split(arg), res)
+ def test_splitdict(self):
+ splitdict = tkinter._splitdict
+ tcl = self.interp.tk
+
+ arg = '-a {1 2 3} -something foo status {}'
+ self.assertEqual(splitdict(tcl, arg, False),
+ {'-a': '1 2 3', '-something': 'foo', 'status': ''})
+ self.assertEqual(splitdict(tcl, arg),
+ {'a': '1 2 3', 'something': 'foo', 'status': ''})
+
+ arg = ('-a', (1, 2, 3), '-something', 'foo', 'status', '{}')
+ self.assertEqual(splitdict(tcl, arg, False),
+ {'-a': (1, 2, 3), '-something': 'foo', 'status': '{}'})
+ self.assertEqual(splitdict(tcl, arg),
+ {'a': (1, 2, 3), 'something': 'foo', 'status': '{}'})
+
+ self.assertRaises(RuntimeError, splitdict, tcl, '-a b -c ')
+ self.assertRaises(RuntimeError, splitdict, tcl, ('-a', 'b', '-c'))
+
+ arg = tcl.call('list',
+ '-a', (1, 2, 3), '-something', 'foo', 'status', ())
+ self.assertEqual(splitdict(tcl, arg),
+ {'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)
+
+
character_size = 4 if sys.maxunicode > 0xFFFF else 2
class BigmemTclTest(unittest.TestCase):