]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Cut traceback on execute short
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 18 Mar 2021 02:27:33 +0000 (03:27 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 18 Mar 2021 02:27:33 +0000 (03:27 +0100)
Users don't care where in psycopg the error comes.

psycopg3/psycopg3/cursor.py

index a6897fc9850cd9a6c9863757fbb488fd2a1478b8..2a8ad986d1712db889ffc4880a3b000de8209bb3 100644 (file)
@@ -502,8 +502,13 @@ class Cursor(BaseCursor["Connection"]):
         """
         Execute a query or command to the database.
         """
-        with self._conn.lock:
-            self._conn.wait(self._execute_gen(query, params, prepare=prepare))
+        try:
+            with self._conn.lock:
+                self._conn.wait(
+                    self._execute_gen(query, params, prepare=prepare)
+                )
+        except e.Error as ex:
+            raise ex.with_traceback(None)
         return self
 
     def executemany(self, query: Query, params_seq: Sequence[Params]) -> None:
@@ -629,10 +634,13 @@ class AsyncCursor(BaseCursor["AsyncConnection"]):
         *,
         prepare: Optional[bool] = None,
     ) -> "AsyncCursor":
-        async with self._conn.lock:
-            await self._conn.wait(
-                self._execute_gen(query, params, prepare=prepare)
-            )
+        try:
+            async with self._conn.lock:
+                await self._conn.wait(
+                    self._execute_gen(query, params, prepare=prepare)
+                )
+        except e.Error as ex:
+            raise ex.with_traceback(None)
         return self
 
     async def executemany(