aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2011-10-20 15:13:46 +0200
committerArmin Rigo <arigo@tunes.org>2011-10-20 15:13:46 +0200
commita717d3373ee607fc165b6ef2e48c4ee5432730eb (patch)
tree77373bfe92ea3461ac5ce280882b7700c2137209 /lib_pypy/pyrepl
parentMaybe fixes solaris for now. (diff)
downloadpypy-a717d3373ee607fc165b6ef2e48c4ee5432730eb.tar.gz
pypy-a717d3373ee607fc165b6ef2e48c4ee5432730eb.tar.bz2
pypy-a717d3373ee607fc165b6ef2e48c4ee5432730eb.zip
Fix: the case marked as "#PyPy" was never actually followed any more.
It is doing something better than the other case, so use it again. It also fixes issue917 on the interactive prompt.
Diffstat (limited to 'lib_pypy/pyrepl')
-rw-r--r--lib_pypy/pyrepl/readline.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib_pypy/pyrepl/readline.py b/lib_pypy/pyrepl/readline.py
index 682a65e3ca..1c7339e576 100644
--- a/lib_pypy/pyrepl/readline.py
+++ b/lib_pypy/pyrepl/readline.py
@@ -395,9 +395,21 @@ def _setup():
_wrapper.f_in = f_in
_wrapper.f_out = f_out
- if hasattr(sys, '__raw_input__'): # PyPy
- _old_raw_input = sys.__raw_input__
+ if '__pypy__' in sys.builtin_module_names: # PyPy
+
+ def _old_raw_input(prompt=''):
+ # sys.__raw_input__() is only called when stdin and stdout are
+ # as expected and are ttys. If it is the case, then get_reader()
+ # should not really fail in _wrapper.raw_input(). If it still
+ # does, then we will just cancel the redirection and call again
+ # the built-in raw_input().
+ try:
+ del sys.__raw_input__
+ except AttributeError:
+ pass
+ return raw_input(prompt)
sys.__raw_input__ = _wrapper.raw_input
+
else:
# this is not really what readline.c does. Better than nothing I guess
import __builtin__