diff options
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | psycopg/microprotocols.c | 5 |
2 files changed, 11 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2009-03-08 Federico Di Gregorio <fog@initd.org> + + * microprotocols.c: None is always adapted to NULL to avoid + errors when calling adapt on nested types without first checking + for None. + 2009-03-02 Federico Di Gregorio <fog@initd.org> * Applied modified patch from Karsten Hilbert to provide a diff --git a/psycopg/microprotocols.c b/psycopg/microprotocols.c index 4232fd4..f451e7e 100644 --- a/psycopg/microprotocols.c +++ b/psycopg/microprotocols.c @@ -78,6 +78,11 @@ microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) /* 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 quotable object to be its instance */ + + /* None is always adapted to NULL */ + + if (obj == Py_None) + return PyString_FromString("NULL"); Dprintf("microprotocols_adapt: trying to adapt %s", obj->ob_type->tp_name); |
