the module will restrict its seeds to :const:`None`, :class:`int`,
:class:`float`, :class:`str`, :class:`bytes`, and :class:`bytearray`.
+* Deprecated the ``split()`` method of :class:`_tkinter.TkappType` in
+ favour of the ``splitlist()`` method which has more consistent and
+ predicable behavior.
+ (Contributed by Serhiy Storchaka in :issue:`38371`.)
+
Removed
=======
import subprocess
import sys
import os
+import warnings
from test import support
# Skip this test if the _tkinter module wasn't built.
def test_split(self):
split = self.interp.tk.split
call = self.interp.tk.call
- self.assertRaises(TypeError, split)
- self.assertRaises(TypeError, split, 'a', 'b')
- self.assertRaises(TypeError, split, 2)
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', r'\bsplit\b.*\bsplitlist\b',
+ DeprecationWarning)
+ self.assertRaises(TypeError, split)
+ self.assertRaises(TypeError, split, 'a', 'b')
+ self.assertRaises(TypeError, split, 2)
testcases = [
('2', '2'),
('', ''),
expected),
]
for arg, res in testcases:
- self.assertEqual(split(arg), res, msg=arg)
+ with self.assertWarns(DeprecationWarning):
+ self.assertEqual(split(arg), res, msg=arg)
def test_splitdict(self):
splitdict = tkinter._splitdict
PyObject *v;
char *list;
+ if (PyErr_WarnEx(PyExc_DeprecationWarning,
+ "split() is deprecated; consider using splitlist() instead", 1))
+ {
+ return NULL;
+ }
+
if (PyTclObject_Check(arg)) {
Tcl_Obj *value = ((PyTclObject*)arg)->value;
int objc;