Author: Brian Kearns <[email protected]>
Branch:
Changeset: r61060:4cc85256a407
Date: 2013-02-11 01:51 -0500
http://bitbucket.org/pypy/pypy/changeset/4cc85256a407/
Log: apply some fixes to get the pyrepl tests running
diff --git a/lib_pypy/pyrepl/reader.py b/lib_pypy/pyrepl/reader.py
--- a/lib_pypy/pyrepl/reader.py
+++ b/lib_pypy/pyrepl/reader.py
@@ -552,6 +552,8 @@
if not event: # can only happen if we're not blocking
return None
+ translate = True
+
if event.evt == 'key':
self.input_trans.push(event)
elif event.evt == 'scroll':
@@ -559,9 +561,12 @@
elif event.evt == 'resize':
self.refresh()
else:
- pass
+ translate = False
- cmd = self.input_trans.get()
+ if translate:
+ cmd = self.input_trans.get()
+ else:
+ cmd = event.evt, event.data
if cmd is None:
if block:
diff --git a/lib_pypy/pyrepl/readline.py b/lib_pypy/pyrepl/readline.py
--- a/lib_pypy/pyrepl/readline.py
+++ b/lib_pypy/pyrepl/readline.py
@@ -174,13 +174,15 @@
# ____________________________________________________________
class _ReadlineWrapper(object):
- f_in = 0
- f_out = 1
reader = None
saved_history_length = -1
startup_hook = None
config = ReadlineConfig()
+ 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:
console = UnixConsole(self.f_in, self.f_out, encoding=ENCODING)
diff --git a/pypy/module/test_lib_pypy/pyrepl/infrastructure.py
b/pypy/module/test_lib_pypy/pyrepl/infrastructure.py
--- a/pypy/module/test_lib_pypy/pyrepl/infrastructure.py
+++ b/pypy/module/test_lib_pypy/pyrepl/infrastructure.py
@@ -56,7 +56,7 @@
return Event(*ev)
-class TestReader(Reader):
+class BaseTestReader(Reader):
def get_prompt(self, lineno, cursor_on_line):
return ''
@@ -66,7 +66,7 @@
self.dirty = True
-def read_spec(test_spec, reader_class=TestReader):
+def read_spec(test_spec, reader_class=BaseTestReader):
# remember to finish your test_spec with 'accept' or similar!
con = TestConsole(test_spec, verbose=True)
reader = reader_class(con)
diff --git a/pypy/module/test_lib_pypy/pyrepl/test_bugs.py
b/pypy/module/test_lib_pypy/pyrepl/test_bugs.py
--- a/pypy/module/test_lib_pypy/pyrepl/test_bugs.py
+++ b/pypy/module/test_lib_pypy/pyrepl/test_bugs.py
@@ -18,7 +18,7 @@
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from pyrepl.historical_reader import HistoricalReader
-from .infrastructure import EA, TestReader, read_spec
+from .infrastructure import EA, BaseTestReader, read_spec
# this test case should contain as-verbatim-as-possible versions of
# (applicable) bug reports
@@ -26,7 +26,7 @@
import pytest
-class HistoricalTestReader(HistoricalReader, TestReader):
+class HistoricalTestReader(HistoricalReader, BaseTestReader):
pass
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit