Fixed isready() not throwing exception on error

This commit is contained in:
Federico Di Gregorio 2009-01-10 18:48:08 +01:00
parent 5480cf5332
commit aeb5080208
3 changed files with 15 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2009-01-10 Federico Di Gregorio <fog@initd.org>
* psycopg/cursor_type.c: cursor.isready() now raise an exception
when the libpq PQconsumeInput() call fails.
2008-12-04 Federico Di Gregorio <fog@initd.org> 2008-12-04 Federico Di Gregorio <fog@initd.org>
* psycopg/lobject_type.c: fixed memory leak. The patch was kindly * psycopg/lobject_type.c: fixed memory leak. The patch was kindly

View File

@ -1479,17 +1479,24 @@ psyco_curs_fileno(cursorObject *self, PyObject *args)
static PyObject * static PyObject *
psyco_curs_isready(cursorObject *self, PyObject *args) psyco_curs_isready(cursorObject *self, PyObject *args)
{ {
int res;
if (!PyArg_ParseTuple(args, "")) return NULL; if (!PyArg_ParseTuple(args, "")) return NULL;
EXC_IF_CURS_CLOSED(self); EXC_IF_CURS_CLOSED(self);
/* pq_is_busy does its own locking, we don't need anything special but if /* 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 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); Py_INCREF(Py_False);
return Py_False; return Py_False;
} }
else if (res == -1) {
return NULL;
}
else { else {
IFCLEARPGRES(self->pgres); IFCLEARPGRES(self->pgres);
Py_BEGIN_ALLOW_THREADS; Py_BEGIN_ALLOW_THREADS;

View File

@ -137,11 +137,11 @@
<File name="tests/test_dates.py" subtype="Code" buildaction="Nothing" /> <File name="tests/test_dates.py" subtype="Code" buildaction="Nothing" />
<File name="tests/test_lobject.py" subtype="Code" buildaction="Nothing" /> <File name="tests/test_lobject.py" subtype="Code" buildaction="Nothing" />
<File name="tests/test_quote.py" subtype="Code" buildaction="Nothing" /> <File name="tests/test_quote.py" subtype="Code" buildaction="Nothing" />
<File name="psycopg/cursor_type.c.~1~" subtype="Code" buildaction="Nothing" />
<File name="psycopg/lobject.h" subtype="Code" buildaction="Nothing" /> <File name="psycopg/lobject.h" subtype="Code" buildaction="Nothing" />
<File name="psycopg/lobject_int.c" subtype="Code" buildaction="Compile" /> <File name="psycopg/lobject_int.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/lobject_type.c" subtype="Code" buildaction="Compile" /> <File name="psycopg/lobject_type.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/typecast_basic.c.old" subtype="Code" buildaction="Nothing" /> <File name="psycopg/typecast_basic.c.old" subtype="Code" buildaction="Nothing" />
<File name="sandbox/test_isready_connection_closed.py" subtype="Code" buildaction="Nothing" />
</Contents> </Contents>
<compiler ctype="GccCompiler" /> <compiler ctype="GccCompiler" />
<MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" /> <MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" />