]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Shorten server-side cursor execute() tracebacks
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 30 Oct 2021 15:26:54 +0000 (17:26 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 30 Oct 2021 15:26:54 +0000 (17:26 +0200)
psycopg/psycopg/server_cursor.py

index 43ed3c6bf815f95775767a7f5a84859e698124dc..2f4ee7ba4fbc44e709e7582bcb4df127578b2522 100644 (file)
@@ -265,10 +265,14 @@ class ServerCursor(Cursor[Row]):
         """
         if kwargs:
             raise TypeError(f"keyword not supported: {list(kwargs)[0]}")
-        with self._conn.lock:
-            self._conn.wait(
-                self._helper._declare_gen(self, query, params, binary)
-            )
+
+        try:
+            with self._conn.lock:
+                self._conn.wait(
+                    self._helper._declare_gen(self, query, params, binary)
+                )
+        except e.Error as ex:
+            raise ex.with_traceback(None)
 
         return self
 
@@ -381,10 +385,13 @@ class AsyncServerCursor(AsyncCursor[Row]):
     ) -> _AC:
         if kwargs:
             raise TypeError(f"keyword not supported: {list(kwargs)[0]}")
-        async with self._conn.lock:
-            await self._conn.wait(
-                self._helper._declare_gen(self, query, params, binary)
-            )
+        try:
+            async with self._conn.lock:
+                await self._conn.wait(
+                    self._helper._declare_gen(self, query, params, binary)
+                )
+        except e.Error as ex:
+            raise ex.with_traceback(None)
 
         return self