summaryrefslogtreecommitdiff
path: root/source3/python/py_tdbpack.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/python/py_tdbpack.c')
-rw-r--r--source3/python/py_tdbpack.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c
index 06aebe61eb..e5044943be 100644
--- a/source3/python/py_tdbpack.c
+++ b/source3/python/py_tdbpack.c
@@ -329,35 +329,18 @@ pytdbpack_calc_reqd_len(char *format_str,
}
-static PyObject *pytdbpack_bad_type(char ch,
- const char *expected,
- PyObject *val_obj)
-{
- PyObject *r = PyObject_Repr(val_obj);
- if (!r)
- return NULL;
- PyErr_Format(PyExc_TypeError,
- "tdbpack: format '%c' requires %s, not %s",
- ch, expected, PyString_AS_STRING(r));
- Py_DECREF(r);
- return val_obj;
-}
-
-
/*
- * Calculate the number of bytes required to pack a single value. While doing
- * this, also conduct some initial checks that the argument types are
- * reasonable.
- *
- * Returns -1 on exception.
- */
+ Calculate the number of bytes required to pack a single value.
+*/
static int
pytdbpack_calc_item_len(char ch,
PyObject *val_obj)
{
if (ch == 'd' || ch == 'w') {
if (!PyInt_Check(val_obj)) {
- pytdbpack_bad_type(ch, "Int", val_obj);
+ PyErr_Format(PyExc_TypeError,
+ "tdbpack: format '%c' requires an Int",
+ ch);
return -1;
}
if (ch == 'w')
@@ -370,7 +353,10 @@ pytdbpack_calc_item_len(char ch,
else if (ch == 'f' || ch == 'P' || ch == 'B') {
/* nul-terminated 8-bit string */
if (!PyString_Check(val_obj)) {
- pytdbpack_bad_type(ch, "String", val_obj);
+ PyErr_Format(PyExc_TypeError,
+ "tdbpack: format '%c' requires a String",
+ ch);
+ return -1;
}
if (ch == 'B') {
@@ -385,7 +371,7 @@ pytdbpack_calc_item_len(char ch,
}
else {
PyErr_Format(PyExc_ValueError,
- "tdbpack: format character '%c' is not supported",
+ __FUNCTION__ ": format character '%c' is not supported",
ch);
return -1;