From cadcffbae5544cffd87a02e07d886f6aa4db65aa Mon Sep 17 00:00:00 2001 From: Kreusada Tagiazala <67752638+Kreusada@users.noreply.github.com> Date: Tue, 23 Aug 2022 01:32:02 +0100 Subject: [PATCH] [Dev] Fix `__repr__()` errors in REPL when referencing an instance of a class & catch Exception (#5794) * initial fix (test) * Replace instances of bare excepts by catching Exception --- redbot/core/dev_commands.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/redbot/core/dev_commands.py b/redbot/core/dev_commands.py index f3bdddf56..b5c5a7033 100644 --- a/redbot/core/dev_commands.py +++ b/redbot/core/dev_commands.py @@ -204,7 +204,7 @@ class Dev(commands.Cog): try: with redirect_stdout(stdout): result = await func() - except: + except Exception: printed = "{}{}".format(stdout.getvalue(), traceback.format_exc()) else: printed = stdout.getvalue() @@ -293,13 +293,16 @@ class Dev(commands.Cog): else: result = executor(code, env) result = await self.maybe_await(result) - except: + except Exception: value = stdout.getvalue() msg = "{}{}".format(value, traceback.format_exc()) else: value = stdout.getvalue() if result is not None: - msg = "{}{}".format(value, result) + try: + msg = "{}{}".format(value, result) + except Exception: + msg = "{}{}".format(value, traceback.format_exc()) env["_"] = result elif value: msg = "{}".format(value)