From 3773b50bb388c0edad2dbc0f6e3dee71012c608f Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 9 Jul 2010 23:10:11 +0100 Subject: [PATCH] Propagate iterable exceptions to the executemany caller. --- ChangeLog | 5 +++++ psycopg/cursor_type.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5500cfdd..6af08424 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-07-09 Daniele Varrazzo + + * psycopg/cursor_type.c: executemany() propagates exceptions raised by the + iterable to the caller. + 2010-05-20 Daniele Varrazzo * psycopg/typecast_datetime.c: Round seconds in historical timezones to diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 17d19721..9e874858 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -534,8 +534,13 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs) Py_XDECREF(iter); self->rowcount = rowcount; - Py_INCREF(Py_None); - return Py_None; + if (!PyErr_Occurred()) { + Py_INCREF(Py_None); + return Py_None; + } + else { + return NULL; + } }