[pypy-svn] r80034 - in pypy/branch/fast-forward/pypy/translator/goal: . test2
arigo at codespeak.net
arigo at codespeak.net
Mon Dec 13 14:59:51 CET 2010
Author: arigo
Date: Mon Dec 13 14:59:48 2010
New Revision: 80034
Modified:
pypy/branch/fast-forward/pypy/translator/goal/app_main.py
pypy/branch/fast-forward/pypy/translator/goal/test2/test_app_main.py
Log:
With this particular (custom) logic, then we mimic more closely CPython's
sys.flags.inspect and sys.flags.interactive. It also allows us to pass
a previously skipped test.
Modified: pypy/branch/fast-forward/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/branch/fast-forward/pypy/translator/goal/app_main.py (original)
+++ pypy/branch/fast-forward/pypy/translator/goal/app_main.py Mon Dec 13 14:59:48 2010
@@ -360,6 +360,8 @@
if not sys.argv: # (relevant in case of "reload(sys)")
sys.argv.append('')
options["run_stdin"] = True
+ if not options["ignore_environment"] and os.getenv('PYTHONINSPECT'):
+ options["inspect"] = True
if print_sys_flags:
flag_opts = ["%s=%s" % (opt, int(value))
for opt, value in options.iteritems()
@@ -373,6 +375,7 @@
return options
def run_command_line(interactive,
+ inspect,
run_command,
no_site,
run_module,
@@ -427,15 +430,17 @@
signal.signal(signal.SIGXFSZ, signal.SIG_IGN)
def inspect_requested():
- # We get an interactive prompt in one of the following two cases:
+ # We get an interactive prompt in one of the following three cases:
#
- # * insepct=True, either from the "-i" option or from the fact that
- # we printed the banner;
+ # * interactive=True, from the "-i" option
+ # or
+ # * inspect=True and stdin is a tty
# or
# * PYTHONINSPECT is set and stdin is a tty.
#
return (interactive or
- (readenv and os.getenv('PYTHONINSPECT') and sys.stdin.isatty()))
+ ((inspect or (readenv and os.getenv('PYTHONINSPECT')))
+ and sys.stdin.isatty()))
success = True
@@ -485,7 +490,7 @@
exec co_python_startup in mainmodule.__dict__
run_toplevel(run_it)
# Then we need a prompt.
- interactive = True
+ inspect = True
else:
# If not interactive, just read and execute stdin normally.
def run_it():
Modified: pypy/branch/fast-forward/pypy/translator/goal/test2/test_app_main.py
==============================================================================
--- pypy/branch/fast-forward/pypy/translator/goal/test2/test_app_main.py (original)
+++ pypy/branch/fast-forward/pypy/translator/goal/test2/test_app_main.py Mon Dec 13 14:59:48 2010
@@ -331,17 +331,16 @@
child.expect('>>> ')
def test_clear_pythoninspect(self):
- py.test.skip("obscure difference with CPython -- do we care?")
- old = os.environ.get('PYTHONINSPECT', '')
+ os.environ['PYTHONINSPECT_'] = '1'
try:
path = getscript("""
import os
del os.environ['PYTHONINSPECT']
""")
child = self.spawn([path])
- xxx # do we expect a prompt or not? CPython gives one
+ child.expect('>>> ')
finally:
- os.environ['PYTHONINSPECT'] = old
+ del os.environ['PYTHONINSPECT_']
def test_stdout_flushes_before_stdin_blocks(self):
# This doesn't really test app_main.py, but a behavior that
More information about the Pypy-commit
mailing list