Harrison/tools exp (#372)

This commit is contained in:
Harrison Chase
2022-12-18 21:51:23 -05:00
committed by GitHub
parent e7b625fe03
commit cf98f219f9
35 changed files with 1033 additions and 376 deletions

View File

@@ -16,7 +16,11 @@ class PythonREPL:
"""Run command with own globals/locals and returns anything printed."""
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
exec(command, self._globals, self._locals)
sys.stdout = old_stdout
output = mystdout.getvalue()
try:
exec(command, self._globals, self._locals)
sys.stdout = old_stdout
output = mystdout.getvalue()
except Exception as e:
sys.stdout = old_stdout
output = str(e)
return output