summaryrefslogtreecommitdiff
path: root/psycopg/pqpath.c
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2017-04-05 14:05:59 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2017-04-05 14:54:07 +0100
commita66c34a6d098623617d675191a4c82f60de1d662 (patch)
treed853b8e9a6407c129e583cc49a19a61538aa2d72 /psycopg/pqpath.c
parent47f5e97759879543edd8ee8ad9032ef67ec0567a (diff)
downloadpsycopg2-a66c34a6d098623617d675191a4c82f60de1d662.tar.gz
Don't clobber a Python exception with an unknown error
Close #410
Diffstat (limited to 'psycopg/pqpath.c')
-rw-r--r--psycopg/pqpath.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c
index f270ce8..5572072 100644
--- a/psycopg/pqpath.c
+++ b/psycopg/pqpath.c
@@ -451,6 +451,10 @@ pq_complete_error(connectionObject *conn, PGresult **pgres, char **error)
else {
if (*error != NULL) {
PyErr_SetString(OperationalError, *error);
+ } else if (PyErr_Occurred()) {
+ /* There was a Python error (e.g. in the callback). Don't clobber
+ * it with an unknown exception. (see #410) */
+ Dprintf("pq_complete_error: forwarding Python exception");
} else {
PyErr_SetString(OperationalError, "unknown error");
}