def main(json_input: str): data = json.loads(json_input) execArgs = ExecArgs(**data) update_settings(data) start = time() return_info = ReturnInfo("", "{}", None, None) try: return_info = exec_input(execArgs) except (KeyboardInterrupt, SystemExit): raise except UserError as e: return_info.userError = pickle_user_error(e.traceback_exception) return_info.userErrorMsg = e.friendly_message return_info.userVariables = e.varsSoFar return_info.execTime = e.execTime except Exception as e: return_info.internalError = "Sorry, AREPL has ran into an error\n\n" + traceback.format_exc( ) return_info.totalPyTime = time() - start print_output(return_info) return return_info
def test_error_has_extended_traceback_1(): try: python_evaluator.exec_input( python_evaluator.ExecArgs(""" try: x except NameError as e: x=1/0 """)) except (KeyboardInterrupt, SystemExit): raise except python_evaluator.UserError as e: json = pickle_user_error(e.traceback_exception) assert "ZeroDivisionError" in json assert "NameError" in json