[pypy-commit] pyrepl default: support filenos as args for readline wrapper
RonnyPfannschmidt
noreply at buildbot.pypy.org
Sun Feb 10 00:55:27 CET 2013
Author: Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
Branch:
Changeset: r229:b7de2cb80611
Date: 2013-01-18 09:38 +0100
http://bitbucket.org/pypy/pyrepl/changeset/b7de2cb80611/
Log: support filenos as args for readline wrapper
diff --git a/pyrepl/readline.py b/pyrepl/readline.py
--- a/pyrepl/readline.py
+++ b/pyrepl/readline.py
@@ -182,9 +182,9 @@
startup_hook = None
config = ReadlineConfig()
- def __init__(self):
- self.f_in = os.dup(0)
- self.f_out = os.dup(1)
+ def __init__(self, f_in=None, f_out=None):
+ self.f_in = f_in if f_in is not None else os.dup(0)
+ self.f_out = f_out if f_out is not None else os.dup(1)
def get_reader(self):
if self.reader is None:
diff --git a/testing/test_readline.py b/testing/test_readline.py
--- a/testing/test_readline.py
+++ b/testing/test_readline.py
@@ -4,11 +4,12 @@
def test_raw_input():
- readline_wrapper = _ReadlineWrapper()
master, slave = pty.openpty()
- readline_wrapper.f_in = slave
+ readline_wrapper = _ReadlineWrapper(slave, slave)
os.write(master, b'input\n')
- result = readline_wrapper.raw_input('prompt:')
+
+ result = readline_wrapper.get_reader().readline()
+ #result = readline_wrapper.raw_input('prompt:')
assert result == 'input'
# A bytes string on python2, a unicode string on python3.
assert isinstance(result, str)
More information about the pypy-commit
mailing list