diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-11-06 14:10:48 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-11-06 14:10:48 (GMT) |
commit | 864741b2c7aaabda736f917694a1d3b26700e8e3 (patch) | |
tree | 8a79396976bd3f512eec73f88abfb60ca787377e /Objects | |
parent | 08ad2fbc7f7abb687327b22eb7f65ac388742ab9 (diff) | |
download | cpython-864741b2c7aaabda736f917694a1d3b26700e8e3.zip cpython-864741b2c7aaabda736f917694a1d3b26700e8e3.tar.gz cpython-864741b2c7aaabda736f917694a1d3b26700e8e3.tar.bz2 |
Issue #13350: Replace most usages of PyUnicode_Format by PyUnicode_FromFormat.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/listobject.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index bbc529a..cf4f276 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2121,9 +2121,8 @@ static PyObject * listindex(PyListObject *self, PyObject *args) { Py_ssize_t i, start=0, stop=Py_SIZE(self); - PyObject *v, *format_tuple, *err_string; + PyObject *v; PyObject *start_obj = NULL, *stop_obj = NULL; - static PyObject *err_format = NULL; if (!PyArg_ParseTuple(args, "O|OO:index", &v, &start_obj, &stop_obj)) return NULL; @@ -2153,20 +2152,7 @@ listindex(PyListObject *self, PyObject *args) else if (cmp < 0) return NULL; } - if (err_format == NULL) { - err_format = PyUnicode_FromString("%r is not in list"); - if (err_format == NULL) - return NULL; - } - format_tuple = PyTuple_Pack(1, v); - if (format_tuple == NULL) - return NULL; - err_string = PyUnicode_Format(err_format, format_tuple); - Py_DECREF(format_tuple); - if (err_string == NULL) - return NULL; - PyErr_SetObject(PyExc_ValueError, err_string); - Py_DECREF(err_string); + PyErr_Format(PyExc_ValueError, "%R is not in list", v); return NULL; } |