Fixed SystemError clobbering libpq errors raised without SQLSTATE

Bug vivisectioned by Eric Snow
<http://archives.postgresql.org/psycopg/2011-04/msg00019.php>.
This commit is contained in:
Daniele Varrazzo 2011-04-24 02:57:04 +01:00
parent 746afdf69f
commit c08799b0b0
2 changed files with 7 additions and 0 deletions

2
NEWS
View File

@ -6,6 +6,8 @@ What's new in psycopg 2.4.1
- Don't fail connection if the client encoding is a non-normalized
variant. Issue reported by Peter Eisentraut.
- Correctly detect an empty query sent to the backend (ticket #46).
- Fixed a SystemError clobbering libpq errors raised without SQLSTATE.
Bug vivisectioned by Eric Snow.
- Allow to specify --static-libpq on setup.py command line instead of
just in 'setup.cfg'. Patch provided by Matthew Ryan (ticket #48).

View File

@ -194,6 +194,11 @@ pq_raise(connectionObject *conn, cursorObject *curs, PGresult *pgres)
if (code != NULL) {
exc = exception_from_sqlstate(code);
}
else {
/* Fallback if there is no exception code (reported happening e.g.
* when the connection is closed). */
exc = DatabaseError;
}
/* try to remove the initial "ERROR: " part from the postgresql error */
err2 = strip_severity(err);