Michael Hudson <mwh21@cam.ac.uk>:
Removed PyErr_BadArgument() calls and replaced them with more useful
error messages.
diff --git a/Objects/listobject.c b/Objects/listobject.c
index f70d19b..661a53b 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -388,7 +388,9 @@
int i;
PyListObject *np;
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;
}
#define b ((PyListObject *)bb)
@@ -469,7 +471,9 @@
}
}
else {
- PyErr_BadArgument();
+ PyErr_Format(PyExc_TypeError,
+ "must assign list (not \"%.200s\") to slice",
+ v->ob_type->tp_name);
return -1;
}
if (ilow < 0)
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index f17fbf1..ce6548b 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -293,7 +293,9 @@
if (!PyString_Check(bb)) {
if (PyUnicode_Check(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;
}
#define b ((PyStringObject *)bb)
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index d5d6a07..c26b7df 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -361,7 +361,9 @@
register int i;
PyTupleObject *np;
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;
}
#define b ((PyTupleObject *)bb)