summaryrefslogtreecommitdiff
path: root/psycopg/connection_int.c
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-01-03 21:43:02 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-01-03 21:43:02 +0100
commit80bd6e27946ed5b56b01687913369d6c895598cb (patch)
tree70f67cdc4c4e73a6e8ac7f4862d3d0b02a1ab99b /psycopg/connection_int.c
parenta01700d478765e8dc6044336f21fe84808569a0d (diff)
parent627df159958330b54011e378427275b0494be013 (diff)
downloadpsycopg2-80bd6e27946ed5b56b01687913369d6c895598cb.tar.gz
Merge branch 'python2' into python3
Conflicts: NEWS-2.3 psycopg/connection_type.c tests/test_connection.py tests/types_basic.py
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r--psycopg/connection_int.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index 6dc7ebb..882b0ef 100644
--- a/psycopg/connection_int.c
+++ b/psycopg/connection_int.c
@@ -823,7 +823,17 @@ conn_poll(connectionObject *self)
if (res == PSYCO_POLL_OK && self->async_cursor) {
/* An async query has just finished: parse the tuple in the
* target cursor. */
- cursorObject *curs = (cursorObject *)self->async_cursor;
+ cursorObject *curs;
+ PyObject *py_curs = PyWeakref_GetObject(self->async_cursor);
+ if (Py_None == py_curs) {
+ pq_clear_async(self);
+ PyErr_SetString(InterfaceError,
+ "the asynchronous cursor has disappeared");
+ res = PSYCO_POLL_ERROR;
+ break;
+ }
+
+ curs = (cursorObject *)py_curs;
IFCLEARPGRES(curs->pgres);
curs->pgres = pq_get_last_result(self);
@@ -835,8 +845,7 @@ conn_poll(connectionObject *self)
}
/* We have finished with our async_cursor */
- Py_XDECREF(self->async_cursor);
- self->async_cursor = NULL;
+ Py_CLEAR(self->async_cursor);
}
break;