diff options
author | Federico Di Gregorio <fog@initd.org> | 2005-02-28 15:50:55 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2005-02-28 15:50:55 +0000 |
commit | cd672525e10826231576e6eb5ab256df1bfed72c (patch) | |
tree | f6d2add7b330b9c73a950ce6fee0ea9254d12f81 /psycopg/microprotocols.c | |
parent | 1ec3c837203661efd9441e2509351156b4a53a40 (diff) | |
download | psycopg2-cd672525e10826231576e6eb5ab256df1bfed72c.tar.gz |
Adaptation fixes (a lot.)
Diffstat (limited to 'psycopg/microprotocols.c')
-rw-r--r-- | psycopg/microprotocols.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/psycopg/microprotocols.c b/psycopg/microprotocols.c index c9c2af8..9675d91 100644 --- a/psycopg/microprotocols.c +++ b/psycopg/microprotocols.c @@ -58,8 +58,7 @@ microprotocols_add(PyTypeObject *type, PyObject *proto, PyObject *cast) { if (proto == NULL) proto = (PyObject*)&isqlquoteType; - Dprintf("microprotocols_add: cast %p for (%s, ?)", - cast, type->tp_name); + Dprintf("microprotocols_add: cast %p for (%s, ?)", cast, type->tp_name); PyDict_SetItem(psyco_adapters, Py_BuildValue("(OO)", (PyObject*)type, proto), @@ -78,6 +77,8 @@ microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) because the ISQLQuote type is abstract and there is no way to get a quotable object to be its instance */ + Dprintf("microprotocols_adapt: trying to adapt %s", obj->ob_type->tp_name); + /* look for an adapter in the registry */ key = Py_BuildValue("(OO)", (PyObject*)obj->ob_type, proto); adapter = PyDict_GetItem(psyco_adapters, key); @@ -95,14 +96,14 @@ microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } - /* and finally try to have the object adapt itself */ + /* and finally try to have the object adapt itself */ if (PyObject_HasAttrString(obj, "__conform__")) { - PyObject *adapted = PyObject_CallMethod(proto, "__conform__","O", obj); + PyObject *adapted = PyObject_CallMethod(obj, "__conform__","O", proto); if (adapted && adapted != Py_None) return adapted; if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_TypeError)) return NULL; } - + /* else set the right exception and return NULL */ PyErr_SetString(ProgrammingError, "can't adapt"); return NULL; |