summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2011-11-06 14:10:48 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2011-11-06 14:10:48 (GMT)
commit864741b2c7aaabda736f917694a1d3b26700e8e3 (patch)
tree8a79396976bd3f512eec73f88abfb60ca787377e /Objects
parent08ad2fbc7f7abb687327b22eb7f65ac388742ab9 (diff)
downloadcpython-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.c18
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;
}