mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Pass dict for locals and globals to exec() (#2590)
This commit is contained in:
parent
bceffd96c6
commit
543f391096
1 changed files with 7 additions and 5 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue