import ast def process(node): exception = ast.nextPRegister() ast.outputInBlock( "new %s, .Exception" % ( exception ) ) if node.expr1: ast.outputInBlock( "%s[\"type\"] = %s" % ( exception, ast.evaluate( node.expr1 ) ) ) if node.expr2: ast.outputInBlock( "%s[\"value\"] = %s" % ( exception, ast.evaluate( node.expr2 ) ) ) if node.expr3: ast.outputInBlock( "%s[\"traceback\"] = %s" % ( exception, ast.evaluate( node.expr3 ) ) ) ast.outputInBlock( "throw %s" % ( exception ) )