diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 06aa8c1..0ab0669 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -971,11 +971,11 @@ python-profiler package from non-free.""") if cell is None: # called as line magic - ast_setup = ast.parse("pass") - ast_stmt = ast.parse(transform(stmt)) + ast_setup = self.shell.compile.ast_parse("pass") + ast_stmt = self.shell.compile.ast_parse(transform(stmt)) else: - ast_setup = ast.parse(transform(stmt)) - ast_stmt = ast.parse(transform(cell)) + ast_setup = self.shell.compile.ast_parse(transform(stmt)) + ast_stmt = self.shell.compile.ast_parse(transform(cell)) ast_setup = self.shell.transform_ast(ast_setup) ast_stmt = self.shell.transform_ast(ast_stmt) @@ -999,7 +999,7 @@ python-profiler package from non-free.""") tc_min = 0.1 t0 = clock() - code = compile(timeit_ast, "", "exec") + code = self.shell.compile(timeit_ast, "", "exec") tc = clock()-t0 ns = {} @@ -1095,7 +1095,7 @@ python-profiler package from non-free.""") tp_min = 0.1 t0 = clock() - expr_ast = ast.parse(expr) + expr_ast = self.shell.compile.ast_parse(expr) tp = clock()-t0 # Apply AST transformations @@ -1112,7 +1112,7 @@ python-profiler package from non-free.""") mode = 'exec' source = '' t0 = clock() - code = compile(expr_ast, source, mode) + code = self.shell.compile(expr_ast, source, mode) tc = clock()-t0 # skew measurement as little as possible diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 00ca802..ea617bc 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -385,6 +385,7 @@ def test_time3(): def test_time_futures(): "Test %time with __future__ environments" ip = get_ipython() + ip.autocall = 0 ip.run_cell("from __future__ import division") with tt.AssertPrints('0.25'): ip.run_line_magic('time', 'print(1/4)')