Author: Antonio Cuni <anto.c...@gmail.com> Branch: py3k Changeset: r55484:7cf90c1c8168 Date: 2012-06-07 22:09 +0200 http://bitbucket.org/pypy/pypy/changeset/7cf90c1c8168/
Log: fix test_print_info by making app_main importable on python2 diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py --- a/pypy/translator/goal/app_main.py +++ b/pypy/translator/goal/app_main.py @@ -16,6 +16,8 @@ --info print translation information about this PyPy executable """ +from __future__ import print_function, unicode_literals + import sys DEBUG = False # dump exceptions before calling the except hook @@ -533,6 +535,11 @@ return options +# this indirection is needed to be able to import this module on python2, else +# we have a SyntaxError: unqualified exec in a nested function +def exec_(src, dic): + exec(src, dic) + def run_command_line(interactive, inspect, run_command, @@ -606,7 +613,7 @@ sys.path.insert(0, '') def run_it(): - exec(run_command, mainmodule.__dict__) + exec_(run_command, mainmodule.__dict__) success = run_toplevel(run_it) elif run_module: # handle the "-m" command @@ -642,7 +649,7 @@ co_python_startup = compile(startup, python_startup, 'exec') - exec(co_python_startup, mainmodule.__dict__) + exec_(co_python_startup, mainmodule.__dict__) run_toplevel(run_it) # Then we need a prompt. inspect = True @@ -650,7 +657,7 @@ # If not interactive, just read and execute stdin normally. def run_it(): co_stdin = compile(sys.stdin.read(), '<stdin>', 'exec') - exec(co_stdin, mainmodule.__dict__) + exec_(co_stdin, mainmodule.__dict__) mainmodule.__file__ = '<stdin>' success = run_toplevel(run_it) else: @@ -683,7 +690,7 @@ def execfile(filename, namespace): with open(filename) as f: code = f.read() - exec(code, namespace) + exec_(code, namespace) args = (execfile, filename, mainmodule.__dict__) success = run_toplevel(*args) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit