From 543f391096903c29f096e8d4b3becd1389c18a31 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Tue, 25 Jul 2023 13:21:06 +0200 Subject: [PATCH] Pass dict for locals and globals to exec() (#2590) --- qt/aqt/debug_console.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qt/aqt/debug_console.py b/qt/aqt/debug_console.py index f22400782..a24ade4fc 100644 --- a/qt/aqt/debug_console.py +++ b/qt/aqt/debug_console.py @@ -282,14 +282,16 @@ class DebugConsole(QDialog): import traceback text = self._text.toPlainText() - card = self._debugCard - bcard = self._debugBrowserCard - mw = aqt.mw - pp = pprint.pprint + vars = { + "card": self._debugCard, + "bcard": self._debugBrowserCard, + "mw": aqt.mw, + "pp": pprint.pprint, + } self._captureOutput(True) try: # pylint: disable=exec-used - exec(text) + exec(text, vars) except: self._output += traceback.format_exc() self._captureOutput(False)