public object ToPythonException() { DynamicType exType = ExceptionConverter.GetPythonExceptionByName(PythonExceptionName); object inst = Ops.Call(exType); Ops.SetAttr(DefaultContext.Default, inst, SymbolTable.ExceptionMessage, base.Message); Ops.SetAttr(DefaultContext.Default, inst, SymbolTable.Arguments, Tuple.MakeTuple( base.Message, Tuple.MakeTuple( file, lineNo, columnNo == 0 ? null : (object)columnNo, lineText ) )); Ops.SetAttr(DefaultContext.Default, inst, SymbolTable.ExceptionFilename, file); Ops.SetAttr(DefaultContext.Default, inst, SymbolTable.ExceptionLineNumber, lineNo); if (columnNo != 0) { Ops.SetAttr(DefaultContext.Default, inst, SymbolTable.ExceptionOffset, columnNo); } else { Ops.SetAttr(DefaultContext.Default, inst, SymbolTable.ExceptionOffset, null); } Ops.SetAttr(DefaultContext.Default, inst, SymbolTable.Text, lineText); // print_file_and_line return(inst); }
public void exit(object code) { // throw as a python exception here to get the args set. throw ExceptionConverter.CreateThrowable(ExceptionConverter.GetPythonExceptionByName("SystemExit"), code); }
public void exit() { throw ExceptionConverter.CreateThrowable(ExceptionConverter.GetPythonExceptionByName("SystemExit")); }