From: Daniele Varrazzo Date: Sun, 2 Jan 2022 19:06:45 +0000 (+0100) Subject: Shorten traceback on executemany X-Git-Tag: pool-3.1~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d49e5d17f8abf19f7381b6ec86f12e8aaf03b958;p=thirdparty%2Fpsycopg.git Shorten traceback on executemany --- diff --git a/psycopg/psycopg/cursor.py b/psycopg/psycopg/cursor.py index 5833122db..8527cf9d3 100644 --- a/psycopg/psycopg/cursor.py +++ b/psycopg/psycopg/cursor.py @@ -574,8 +574,11 @@ class Cursor(BaseCursor["Connection[Any]", Row]): """ Execute the same command with a sequence of input data. """ - with self._conn.lock: - self._conn.wait(self._executemany_gen(query, params_seq)) + try: + with self._conn.lock: + self._conn.wait(self._executemany_gen(query, params_seq)) + except e.Error as ex: + raise ex.with_traceback(None) def stream( self, diff --git a/psycopg/psycopg/cursor_async.py b/psycopg/psycopg/cursor_async.py index f9d7109db..1e34bef65 100644 --- a/psycopg/psycopg/cursor_async.py +++ b/psycopg/psycopg/cursor_async.py @@ -84,8 +84,11 @@ class AsyncCursor(BaseCursor["AsyncConnection[Any]", Row]): async def executemany( self, query: Query, params_seq: Iterable[Params] ) -> None: - async with self._conn.lock: - await self._conn.wait(self._executemany_gen(query, params_seq)) + try: + async with self._conn.lock: + await self._conn.wait(self._executemany_gen(query, params_seq)) + except e.Error as ex: + raise ex.with_traceback(None) async def stream( self,