From 709df38d7912ec1ad06f65ebddb2ee097adf66c7 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sun, 5 Jun 2011 16:30:37 +0100 Subject: [PATCH] Don't clobber an eventual Python exception set by a green thread --- psycopg/pqpath.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index f50b00b4..0e5b2490 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -343,12 +343,12 @@ pq_execute_command_locked(connectionObject *conn, const char *query, *tstate = PyEval_SaveThread(); } if (*pgres == NULL) { - const char *msg; - Dprintf("pq_execute_command_locked: PQexec returned NULL"); - msg = PQerrorMessage(conn->pgconn); - if (msg) - *error = strdup(msg); + if (!PyErr_Occurred()) { + const char *msg; + msg = PQerrorMessage(conn->pgconn); + if (msg && *msg) { *error = strdup(msg); } + } goto cleanup; } @@ -361,8 +361,8 @@ pq_execute_command_locked(connectionObject *conn, const char *query, retvalue = 0; IFCLEARPGRES(*pgres); - - cleanup: + +cleanup: return retvalue; }