From: Daniele Varrazzo Date: Sat, 30 Oct 2021 15:26:54 +0000 (+0200) Subject: Shorten server-side cursor execute() tracebacks X-Git-Tag: 3.0.2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebb46763370f4d6aeb19b89b1217271ac4d949d6;p=thirdparty%2Fpsycopg.git Shorten server-side cursor execute() tracebacks --- diff --git a/psycopg/psycopg/server_cursor.py b/psycopg/psycopg/server_cursor.py index 43ed3c6bf..2f4ee7ba4 100644 --- a/psycopg/psycopg/server_cursor.py +++ b/psycopg/psycopg/server_cursor.py @@ -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