mirror of https://github.com/python/cpython
bpo-38371: Tkinter: deprecate the split() method. (GH-16584)
This commit is contained in:
parent
d7c387384a
commit
d05b000c6b
|
@ -191,6 +191,11 @@ Deprecated
|
||||||
the module will restrict its seeds to :const:`None`, :class:`int`,
|
the module will restrict its seeds to :const:`None`, :class:`int`,
|
||||||
:class:`float`, :class:`str`, :class:`bytes`, and :class:`bytearray`.
|
: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
|
Removed
|
||||||
=======
|
=======
|
||||||
|
|
|
@ -3,6 +3,7 @@ import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import warnings
|
||||||
from test import support
|
from test import support
|
||||||
|
|
||||||
# Skip this test if the _tkinter module wasn't built.
|
# Skip this test if the _tkinter module wasn't built.
|
||||||
|
@ -573,9 +574,12 @@ class TclTest(unittest.TestCase):
|
||||||
def test_split(self):
|
def test_split(self):
|
||||||
split = self.interp.tk.split
|
split = self.interp.tk.split
|
||||||
call = self.interp.tk.call
|
call = self.interp.tk.call
|
||||||
self.assertRaises(TypeError, split)
|
with warnings.catch_warnings():
|
||||||
self.assertRaises(TypeError, split, 'a', 'b')
|
warnings.filterwarnings('ignore', r'\bsplit\b.*\bsplitlist\b',
|
||||||
self.assertRaises(TypeError, split, 2)
|
DeprecationWarning)
|
||||||
|
self.assertRaises(TypeError, split)
|
||||||
|
self.assertRaises(TypeError, split, 'a', 'b')
|
||||||
|
self.assertRaises(TypeError, split, 2)
|
||||||
testcases = [
|
testcases = [
|
||||||
('2', '2'),
|
('2', '2'),
|
||||||
('', ''),
|
('', ''),
|
||||||
|
@ -617,7 +621,8 @@ class TclTest(unittest.TestCase):
|
||||||
expected),
|
expected),
|
||||||
]
|
]
|
||||||
for arg, res in testcases:
|
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):
|
def test_splitdict(self):
|
||||||
splitdict = tkinter._splitdict
|
splitdict = tkinter._splitdict
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Deprecated the ``split()`` method in :class:`_tkinter.TkappType` in favour
|
||||||
|
of the ``splitlist()`` method which has more consistent and predicable
|
||||||
|
behavior.
|
|
@ -2304,6 +2304,12 @@ _tkinter_tkapp_split(TkappObject *self, PyObject *arg)
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
char *list;
|
char *list;
|
||||||
|
|
||||||
|
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
|
"split() is deprecated; consider using splitlist() instead", 1))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (PyTclObject_Check(arg)) {
|
if (PyTclObject_Check(arg)) {
|
||||||
Tcl_Obj *value = ((PyTclObject*)arg)->value;
|
Tcl_Obj *value = ((PyTclObject*)arg)->value;
|
||||||
int objc;
|
int objc;
|
||||||
|
|
Loading…
Reference in New Issue