From 760db11589c81cfa84c4a3eb1726bf40acbede13 Mon Sep 17 00:00:00 2001 From: Red-GitHubBot <88117545+Red-GitHubBot@users.noreply.github.com> Date: Thu, 20 Apr 2023 00:10:46 +0200 Subject: [PATCH] [3.4] [Dev] Fix `__repr__()` errors in REPL when referencing an instance of a class & catch Exception (#5794) (#6065) Co-authored-by: Kreusada Tagiazala <67752638+Kreusada@users.noreply.github.com> --- 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 1a236c5e6..0a3953905 100644 --- a/redbot/core/dev_commands.py +++ b/redbot/core/dev_commands.py @@ -200,7 +200,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() @@ -289,13 +289,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)