diff --git a/ChangeLog b/ChangeLog index e1b3559b..487943aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-01-10 Federico Di Gregorio + + * psycopg/cursor_type.c: cursor.isready() now raise an exception + when the libpq PQconsumeInput() call fails. + 2008-12-04 Federico Di Gregorio * psycopg/lobject_type.c: fixed memory leak. The patch was kindly diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 3749467e..a85e0303 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -1479,17 +1479,24 @@ psyco_curs_fileno(cursorObject *self, PyObject *args) static PyObject * psyco_curs_isready(cursorObject *self, PyObject *args) { + int res; + if (!PyArg_ParseTuple(args, "")) return NULL; EXC_IF_CURS_CLOSED(self); /* pq_is_busy does its own locking, we don't need anything special but if the cursor is ready we need to fetch the result and free the connection - for the next query. */ + for the next query. if -1 is returned we raise an exception. */ - if (pq_is_busy(self->conn)) { + res = pq_is_busy(self->conn); + + if (res == 1) { Py_INCREF(Py_False); return Py_False; } + else if (res == -1) { + return NULL; + } else { IFCLEARPGRES(self->pgres); Py_BEGIN_ALLOW_THREADS; diff --git a/psycopg2.mdp b/psycopg2.mdp index 99b8ace9..f3dff0fd 100644 --- a/psycopg2.mdp +++ b/psycopg2.mdp @@ -137,11 +137,11 @@ - +