mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Michael Hudson <mwh21@cam.ac.uk>:
Removed PyErr_BadArgument() calls and replaced them with more useful error messages.
This commit is contained in:
parent
94c3452ade
commit
b6a9ada757
3 changed files with 12 additions and 4 deletions
|
@ -388,7 +388,9 @@ list_concat(a, bb)
|
||||||
int i;
|
int i;
|
||||||
PyListObject *np;
|
PyListObject *np;
|
||||||
if (!PyList_Check(bb)) {
|
if (!PyList_Check(bb)) {
|
||||||
PyErr_BadArgument();
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"can only append list (not \"%.200s\") to list",
|
||||||
|
bb->ob_type->tp_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#define b ((PyListObject *)bb)
|
#define b ((PyListObject *)bb)
|
||||||
|
@ -469,7 +471,9 @@ list_ass_slice(a, ilow, ihigh, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_BadArgument();
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"must assign list (not \"%.200s\") to slice",
|
||||||
|
v->ob_type->tp_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ilow < 0)
|
if (ilow < 0)
|
||||||
|
|
|
@ -293,7 +293,9 @@ string_concat(a, bb)
|
||||||
if (!PyString_Check(bb)) {
|
if (!PyString_Check(bb)) {
|
||||||
if (PyUnicode_Check(bb))
|
if (PyUnicode_Check(bb))
|
||||||
return PyUnicode_Concat((PyObject *)a, bb);
|
return PyUnicode_Concat((PyObject *)a, bb);
|
||||||
PyErr_BadArgument();
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"cannot add type \"%.200s\" to string",
|
||||||
|
bb->ob_type->tp_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#define b ((PyStringObject *)bb)
|
#define b ((PyStringObject *)bb)
|
||||||
|
|
|
@ -361,7 +361,9 @@ tupleconcat(a, bb)
|
||||||
register int i;
|
register int i;
|
||||||
PyTupleObject *np;
|
PyTupleObject *np;
|
||||||
if (!PyTuple_Check(bb)) {
|
if (!PyTuple_Check(bb)) {
|
||||||
PyErr_BadArgument();
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"can only append tuple (not \"%.200s\") to tuple",
|
||||||
|
bb->ob_type->tp_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#define b ((PyTupleObject *)bb)
|
#define b ((PyTupleObject *)bb)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue