diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-09-08 20:02:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-08 20:02:19 (GMT) |
commit | f235dd0784b92824565c4a4e72adc70fa3eab68f (patch) | |
tree | 4847c5a1a35b5f311b59a2cc135fccba2ae440e8 /Modules/_tkinter.c | |
parent | 84ca5fcd31541929f0031e974a434b95d8e78aab (diff) | |
download | cpython-f235dd0784b92824565c4a4e72adc70fa3eab68f.zip cpython-f235dd0784b92824565c4a4e72adc70fa3eab68f.tar.gz cpython-f235dd0784b92824565c4a4e72adc70fa3eab68f.tar.bz2 |
bpo-38371: Remove deprecated `tkinter` split() method (GH-28237)
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r-- | Modules/_tkinter.c | 202 |
1 files changed, 0 insertions, 202 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 329b291..7be9b8c 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -506,145 +506,6 @@ unicodeFromTclObj(Tcl_Obj *value) #endif } - -static PyObject * -Split(const char *list) -{ - int argc; - const char **argv; - PyObject *v; - - if (list == NULL) { - Py_RETURN_NONE; - } - - if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) { - /* Not a list. - * Could be a quoted string containing funnies, e.g. {"}. - * Return the string itself. - */ - return unicodeFromTclString(list); - } - - if (argc == 0) - v = PyUnicode_FromString(""); - else if (argc == 1) - v = unicodeFromTclString(argv[0]); - else if ((v = PyTuple_New(argc)) != NULL) { - int i; - PyObject *w; - - for (i = 0; i < argc; i++) { - if ((w = Split(argv[i])) == NULL) { - Py_DECREF(v); - v = NULL; - break; - } - PyTuple_SET_ITEM(v, i, w); - } - } - Tcl_Free(FREECAST argv); - return v; -} - -/* In some cases, Tcl will still return strings that are supposed to - be lists. SplitObj walks through a nested tuple, finding string - objects that need to be split. */ - -static PyObject * -SplitObj(PyObject *arg) -{ - if (PyTuple_Check(arg)) { - Py_ssize_t i, size; - PyObject *elem, *newelem, *result; - - size = PyTuple_GET_SIZE(arg); - result = NULL; - /* Recursively invoke SplitObj for all tuple items. - If this does not return a new object, no action is - needed. */ - for(i = 0; i < size; i++) { - elem = PyTuple_GET_ITEM(arg, i); - newelem = SplitObj(elem); - if (!newelem) { - Py_XDECREF(result); - return NULL; - } - if (!result) { - Py_ssize_t k; - if (newelem == elem) { - Py_DECREF(newelem); - continue; - } - result = PyTuple_New(size); - if (!result) - return NULL; - for(k = 0; k < i; k++) { - elem = PyTuple_GET_ITEM(arg, k); - Py_INCREF(elem); - PyTuple_SET_ITEM(result, k, elem); - } - } - PyTuple_SET_ITEM(result, i, newelem); - } - if (result) - return result; - /* Fall through, returning arg. */ - } - else if (PyList_Check(arg)) { - Py_ssize_t i, size; - PyObject *elem, *newelem, *result; - - size = PyList_GET_SIZE(arg); - result = PyTuple_New(size); - if (!result) - return NULL; - /* Recursively invoke SplitObj for all list items. */ - for(i = 0; i < size; i++) { - elem = PyList_GET_ITEM(arg, i); - newelem = SplitObj(elem); - if (!newelem) { - Py_XDECREF(result); - return NULL; - } - PyTuple_SET_ITEM(result, i, newelem); - } - return result; - } - else if (PyUnicode_Check(arg)) { - int argc; - const char **argv; - const char *list = PyUnicode_AsUTF8(arg); - - if (list == NULL || - Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) { - Py_INCREF(arg); - return arg; - } - Tcl_Free(FREECAST argv); - if (argc > 1) - return Split(list); - /* Fall through, returning arg. */ - } - else if (PyBytes_Check(arg)) { - int argc; - const char **argv; - const char *list = PyBytes_AS_STRING(arg); - - if (Tcl_SplitList((Tcl_Interp *)NULL, (char *)list, &argc, &argv) != TCL_OK) { - Py_INCREF(arg); - return arg; - } - Tcl_Free(FREECAST argv); - if (argc > 1) - return Split(PyBytes_AS_STRING(arg)); - /* Fall through, returning arg. */ - } - Py_INCREF(arg); - return arg; -} - - /*[clinic input] module _tkinter class _tkinter.tkapp "TkappObject *" "&Tkapp_Type_spec" @@ -2342,68 +2203,6 @@ _tkinter_tkapp_splitlist(TkappObject *self, PyObject *arg) return v; } -/*[clinic input] -_tkinter.tkapp.split - - arg: object - / - -[clinic start generated code]*/ - -static PyObject * -_tkinter_tkapp_split(TkappObject *self, PyObject *arg) -/*[clinic end generated code: output=e08ad832363facfd input=a1c78349eacaa140]*/ -{ - 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; - Tcl_Obj **objv; - int i; - if (Tcl_ListObjGetElements(Tkapp_Interp(self), value, - &objc, &objv) == TCL_ERROR) { - return FromObj(self, value); - } - if (objc == 0) - return PyUnicode_FromString(""); - if (objc == 1) - return FromObj(self, objv[0]); - if (!(v = PyTuple_New(objc))) - return NULL; - for (i = 0; i < objc; i++) { - PyObject *s = FromObj(self, objv[i]); - if (!s) { - Py_DECREF(v); - return NULL; - } - PyTuple_SET_ITEM(v, i, s); - } - return v; - } - if (PyTuple_Check(arg) || PyList_Check(arg)) - return SplitObj(arg); - - if (!PyArg_Parse(arg, "et:split", "utf-8", &list)) - return NULL; - if (strlen(list) >= INT_MAX) { - PyErr_SetString(PyExc_OverflowError, "string is too long"); - PyMem_Free(list); - return NULL; - } - v = Split(list); - PyMem_Free(list); - return v; -} - - /** Tcl Command **/ @@ -3331,7 +3130,6 @@ static PyMethodDef Tkapp_methods[] = _TKINTER_TKAPP_EXPRDOUBLE_METHODDEF _TKINTER_TKAPP_EXPRBOOLEAN_METHODDEF _TKINTER_TKAPP_SPLITLIST_METHODDEF - _TKINTER_TKAPP_SPLIT_METHODDEF _TKINTER_TKAPP_CREATECOMMAND_METHODDEF _TKINTER_TKAPP_DELETECOMMAND_METHODDEF _TKINTER_TKAPP_CREATEFILEHANDLER_METHODDEF |