]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Shorten traceback on executemany
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 2 Jan 2022 19:06:45 +0000 (20:06 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 2 Jan 2022 19:47:18 +0000 (20:47 +0100)
psycopg/psycopg/cursor.py
psycopg/psycopg/cursor_async.py

index 5833122dbe311bc65a4a5cf52b76f8eb438a99a1..8527cf9d32d003f26b35f9d632133d62b3299a16 100644 (file)
@@ -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,
index f9d7109db0baae9cedf6721ceff3340124f85772..1e34bef65f2dcb48e3acbe71f64eff39a72085c5 100644 (file)
@@ -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,