[pypy-commit] pyrepl default: Patch from pypy's 0d7e8867e6c0
arigo
noreply at buildbot.pypy.org
Thu Oct 20 15:15:58 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r149:f4d54136a74c
Date: 2011-10-20 15:15 +0200
http://bitbucket.org/pypy/pyrepl/changeset/f4d54136a74c/
Log: Patch from pypy's 0d7e8867e6c0
diff --git a/pyrepl/readline.py b/pyrepl/readline.py
--- a/pyrepl/readline.py
+++ b/pyrepl/readline.py
@@ -395,9 +395,21 @@
_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__
More information about the pypy-commit
mailing list