mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #13350: Replace most usages of PyUnicode_Format by PyUnicode_FromFormat.
This commit is contained in:
parent
08ad2fbc7f
commit
864741b2c7
7 changed files with 13 additions and 107 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue