Pass dict for locals and globals to exec() (#2590)

This commit is contained in:
RumovZ 2023-07-25 13:21:06 +02:00 committed by GitHub
parent bceffd96c6
commit 543f391096
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -282,14 +282,16 @@ class DebugConsole(QDialog):
import traceback import traceback
text = self._text.toPlainText() text = self._text.toPlainText()
card = self._debugCard vars = {
bcard = self._debugBrowserCard "card": self._debugCard,
mw = aqt.mw "bcard": self._debugBrowserCard,
pp = pprint.pprint "mw": aqt.mw,
"pp": pprint.pprint,
}
self._captureOutput(True) self._captureOutput(True)
try: try:
# pylint: disable=exec-used # pylint: disable=exec-used
exec(text) exec(text, vars)
except: except:
self._output += traceback.format_exc() self._output += traceback.format_exc()
self._captureOutput(False) self._captureOutput(False)