From 65ec7e8bcb5f082bdbf6eddadd7ef6e601098fbd Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 8 Mar 2016 05:12:06 +0000 Subject: [PATCH] Fixed read() exception propagation in copy_from Close issue #412. --- NEWS | 1 + psycopg/pqpath.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 8a1b477b..52307ed2 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,7 @@ What's new in psycopg 2.6.2 - Added support for setuptools/wheel (:ticket:`#370`). - Fix build on Windows with Python 3.5, VS 2015 (:ticket:`#380`). - Fixed `!errorcodes.lookup` initialization thread-safety (:ticket:`#382`). +- Fixed `!read()` exception propagation in copy_from (:ticket:`#412`). What's new in psycopg 2.6.1 diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index b643512d..99dd40be 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -1393,7 +1393,11 @@ _pq_copy_in_v3(cursorObject *curs) Py_DECREF(str); } } - PyErr_Restore(t, ex, tb); + /* Clear the Py exception: it will be re-raised from the libpq */ + Py_XDECREF(t); + Py_XDECREF(ex); + Py_XDECREF(tb); + PyErr_Clear(); } res = PQputCopyEnd(curs->conn->pgconn, buf); }