mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
Exceptions raised by the columns iterator propagated.
This commit is contained in:
parent
cb8128c6d4
commit
deb2d9050f
|
@ -7,6 +7,9 @@
|
||||||
projects using logging but where no handler is installed on the root
|
projects using logging but where no handler is installed on the root
|
||||||
logger. Bug reported by Joe Abbate.
|
logger. Bug reported by Joe Abbate.
|
||||||
|
|
||||||
|
* psycopg/cursor_type.c: exceptions raised in the columns iterator of the
|
||||||
|
copy methods propagated to the caller.
|
||||||
|
|
||||||
2010-05-20 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
2010-05-20 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||||
|
|
||||||
* psycopg/typecast_datetime.c: Round seconds in historical timezones to
|
* psycopg/typecast_datetime.c: Round seconds in historical timezones to
|
||||||
|
|
|
@ -1151,6 +1151,11 @@ static int _psyco_curs_copy_columns(PyObject *columns, char *columnlist)
|
||||||
}
|
}
|
||||||
Py_DECREF(coliter);
|
Py_DECREF(coliter);
|
||||||
|
|
||||||
|
/* Error raised by the coliter generator */
|
||||||
|
if (PyErr_Occurred()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (offset == 2) {
|
if (offset == 2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,20 @@ class CopyTests(unittest.TestCase):
|
||||||
curs.execute("select * from tcopy order by id")
|
curs.execute("select * from tcopy order by id")
|
||||||
self.assertEqual([(i, None) for i in range(10)], curs.fetchall())
|
self.assertEqual([(i, None) for i in range(10)], curs.fetchall())
|
||||||
|
|
||||||
|
def test_copy_from_cols_err(self):
|
||||||
|
curs = self.conn.cursor()
|
||||||
|
f = StringIO()
|
||||||
|
for i in xrange(10):
|
||||||
|
f.write("%s\n" % (i,))
|
||||||
|
|
||||||
|
f.seek(0)
|
||||||
|
def cols():
|
||||||
|
raise ZeroDivisionError()
|
||||||
|
yield 'id'
|
||||||
|
|
||||||
|
self.assertRaises(ZeroDivisionError,
|
||||||
|
curs.copy_from, MinimalRead(f), "tcopy", columns=cols())
|
||||||
|
|
||||||
def test_copy_to(self):
|
def test_copy_to(self):
|
||||||
curs = self.conn.cursor()
|
curs = self.conn.cursor()
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user