From: Daniele Varrazzo Date: Thu, 18 Mar 2021 02:27:33 +0000 (+0100) Subject: Cut traceback on execute short X-Git-Tag: 3.0.dev0~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6eec5f9b7a480ae33e6096cd070a0f9db5135f18;p=thirdparty%2Fpsycopg.git Cut traceback on execute short Users don't care where in psycopg the error comes. --- diff --git a/psycopg3/psycopg3/cursor.py b/psycopg3/psycopg3/cursor.py index a6897fc98..2a8ad986d 100644 --- a/psycopg3/psycopg3/cursor.py +++ b/psycopg3/psycopg3/cursor.py @@ -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(