summaryrefslogtreecommitdiff
path: root/psycopg/microprotocols.c
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2009-11-25 11:51:54 +0100
committerFederico Di Gregorio <fog@initd.org>2009-11-25 11:51:54 +0100
commitbcc836c6610638f53a73c393b63bc49476786ec1 (patch)
tree95703cdbdd5a880a2f57e45749999d5ef4965550 /psycopg/microprotocols.c
parentd40a5321f21d26cd800b8a37949f179f878b344c (diff)
downloadpsycopg2-bcc836c6610638f53a73c393b63bc49476786ec1.tar.gz
Now adapt() errors include the type name
Diffstat (limited to 'psycopg/microprotocols.c')
-rw-r--r--psycopg/microprotocols.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/psycopg/microprotocols.c b/psycopg/microprotocols.c
index f451e7e..2499358 100644
--- a/psycopg/microprotocols.c
+++ b/psycopg/microprotocols.c
@@ -74,6 +74,7 @@ PyObject *
microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
{
PyObject *adapter, *key;
+ char buffer[256];
/* we don't check for exact type conformance as specified in PEP 246
because the ISQLQuote type is abstract and there is no way to get a
@@ -114,7 +115,8 @@ microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
}
/* else set the right exception and return NULL */
- psyco_set_error(ProgrammingError, NULL, "can't adapt", NULL, NULL);
+ PyOS_snprintf(buffer, 255, "can't adapt type '%s'", obj->ob_type->tp_name);
+ psyco_set_error(ProgrammingError, NULL, buffer, NULL, NULL);
return NULL;
}