Check return code from decoding the connection status

It fails on Py3 after receiving a SIGABRT. Because we don't handle it
here it will resurface later with nonsense such as:

    SystemError: <some function> returned a result with an error set

Close #551
This commit is contained in:
Daniele Varrazzo 2017-06-15 17:24:54 +01:00
parent de843ef756
commit 602c74faa6
2 changed files with 7 additions and 2 deletions

1
NEWS
View File

@ -18,6 +18,7 @@ What's new in psycopg 2.7.2
(:ticket:`#545`).
- Fixed `~psycopg2.extras.ReplicationCursor.consume_stream()`
*keepalive_interval* argument (:ticket:`#547`).
- Fixed random `!SystemError` upon receiving abort signal (:ticket:`#551`).
- `~psycopg2.errorcodes` map updated to PostgreSQL 10 beta 1.

View File

@ -1893,8 +1893,12 @@ pq_fetch(cursorObject *curs, int no_result)
Dprintf("pq_fetch: pgstatus = %s", PQresStatus(pgstatus));
/* backend status message */
Py_XDECREF(curs->pgstatus);
curs->pgstatus = conn_text_from_chars(curs->conn, PQcmdStatus(curs->pgres));
Py_CLEAR(curs->pgstatus);
if (!(curs->pgstatus = conn_text_from_chars(
curs->conn, PQcmdStatus(curs->pgres)))) {
ex = -1;
return ex;
}
switch(pgstatus) {