[pypy-svn] r79644 - in pypy/trunk: lib_pypy pypy/module/sys pypy/translator/goal pypy/translator/goal/test2
antocuni at codespeak.net
antocuni at codespeak.net
Mon Nov 29 16:35:28 CET 2010
Author: antocuni
Date: Mon Nov 29 16:35:27 2010
New Revision: 79644
Modified:
pypy/trunk/lib_pypy/_pypy_interact.py
pypy/trunk/pypy/module/sys/__init__.py
pypy/trunk/pypy/translator/goal/app_main.py
pypy/trunk/pypy/translator/goal/test2/test_app_main.py
Log:
set sys.{ps1,ps2} only when we enter the interactive prompt. There is code around which relies on it (e.g., my sitecustomize.py :-))
Modified: pypy/trunk/lib_pypy/_pypy_interact.py
==============================================================================
--- pypy/trunk/lib_pypy/_pypy_interact.py (original)
+++ pypy/trunk/lib_pypy/_pypy_interact.py Mon Nov 29 16:35:27 2010
@@ -4,6 +4,13 @@
def interactive_console(mainmodule=None):
+ # set sys.{ps1,ps2} just before invoking the interactive interpreter. This
+ # mimics what CPython does in pythonrun.c
+ if not hasattr(sys, 'ps1'):
+ sys.ps1 = '>>>> '
+ if not hasattr(sys, 'ps1'):
+ sys.ps2 = '.... '
+ #
try:
from _pypy_irc_topic import some_topic
text = "And now for something completely different: ``%s''" % (
@@ -15,6 +22,7 @@
print text
except ImportError:
pass
+ #
try:
from pyrepl.simple_interact import check
if not check():
Modified: pypy/trunk/pypy/module/sys/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/sys/__init__.py (original)
+++ pypy/trunk/pypy/module/sys/__init__.py Mon Nov 29 16:35:27 2010
@@ -60,8 +60,6 @@
'pypy_svn_url' : 'version.get_svn_url(space)',
'subversion' : 'version.get_subversion_info(space)',
'hexversion' : 'version.get_hexversion(space)',
- 'ps1' : 'space.wrap(">>>> ")',
- 'ps2' : 'space.wrap(".... ")',
'displayhook' : 'hook.displayhook',
'__displayhook__' : 'hook.__displayhook__',
Modified: pypy/trunk/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/trunk/pypy/translator/goal/app_main.py (original)
+++ pypy/trunk/pypy/translator/goal/app_main.py Mon Nov 29 16:35:27 2010
@@ -495,13 +495,13 @@
sys.pypy_version_info = PYPY_VERSION
sys.pypy_initial_path = pypy_initial_path
os = nanos.os_module_for_testing
- sys.ps1 = '>>>> '
- sys.ps2 = '.... '
try:
sys.exit(int(entry_point(sys.argv[0], sys.argv[1:], os)))
finally:
- sys.ps1 = '>>> ' # restore the normal ones, in case
- sys.ps2 = '... ' # we are dropping to CPython's prompt
+ # restore the normal prompt (which was changed by _pypy_interact), in
+ # case we are dropping to CPython's prompt
+ sys.ps1 = '>>> '
+ sys.ps2 = '... '
import os; os.environ.update(reset)
assert old_argv is sys.argv
assert old_path is sys.path
Modified: pypy/trunk/pypy/translator/goal/test2/test_app_main.py
==============================================================================
--- pypy/trunk/pypy/translator/goal/test2/test_app_main.py (original)
+++ pypy/trunk/pypy/translator/goal/test2/test_app_main.py Mon Nov 29 16:35:27 2010
@@ -329,6 +329,10 @@
child = self.spawn(['-mpypy.translator.goal.test2.mymodule'])
child.expect('mymodule running')
+ def test_ps1_only_if_interactive(self):
+ argv = ['-c', 'import sys; print hasattr(sys, "ps1")']
+ child = self.spawn(argv)
+ child.expect('False')
class TestNonInteractive:
More information about the Pypy-commit
mailing list