def visit_Exec(self, n: ast27.Exec) -> ExpressionStmt: new_globals = n.globals new_locals = n.locals if new_globals is None: new_globals = ast27.Name("None", ast27.Load(), lineno=-1, col_offset=-1) if new_locals is None: new_locals = ast27.Name("None", ast27.Load(), lineno=-1, col_offset=-1) # TODO: Comment in visit_Print also applies here return self.visit_Expr( ast27.Expr(ast27.Call(ast27.Name("exec", ast27.Load(), lineno=n.lineno, col_offset=-1), [n.body, new_globals, new_locals], [], None, None, lineno=n.lineno, col_offset=-1), lineno=n.lineno, col_offset=-1))
def visit_Print(self, n: ast27.Print) -> ExpressionStmt: keywords = [] if n.dest is not None: keywords.append(ast27.keyword("file", n.dest)) if not n.nl: keywords.append(ast27.keyword("end", ast27.Str(" ", 0, lineno=n.lineno, col_offset=-1))) # TODO: Rather then desugaring Print into an intermediary ast27.Call object, it might # be more efficient to just directly create a mypy.node.CallExpr object. call = ast27.Call( ast27.Name("print", ast27.Load(), lineno=n.lineno, col_offset=-1), n.values, keywords, None, None, lineno=n.lineno, col_offset=-1) return self.visit_Expr(ast27.Expr(call, lineno=n.lineno, col_offset=-1))