1
0

stop using eval

This commit is contained in:
Bryan Stitt
2013-11-11 22:03:20 -08:00
parent d93c642c5c
commit 91061752cf
5 changed files with 16 additions and 10 deletions

View File

@@ -39,6 +39,8 @@ class Console(QtGui.QPlainTextEdit):
def run_script(self, filename):
with open(filename) as f:
script = f.read()
# eval is generally considered bad practice. use it wisely!
result = eval(script, self.namespace, self.namespace)
@@ -209,6 +211,7 @@ class Console(QtGui.QPlainTextEdit):
sys.stdout = stdoutProxy(self.appendPlainText)
try:
try:
# eval is generally considered bad practice. use it wisely!
result = eval(command, self.namespace, self.namespace)
if result != None:
if self.is_json:
@@ -216,6 +219,7 @@ class Console(QtGui.QPlainTextEdit):
else:
self.appendPlainText(repr(result))
except SyntaxError:
# exec is generally considered bad practice. use it wisely!
exec command in self.namespace
except SystemExit:
self.close()