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
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)