[Jython-checkins] jython: Changes to readline.py to pass test_readline.py

jeff.allen jython-checkins at python.org
Sat Sep 7 19:12:44 CEST 2013


http://hg.python.org/jython/rev/6231c3bbcd90
changeset:   7115:6231c3bbcd90
user:        Jeff Allen <ja.py at farowl.co.uk>
date:        Tue Jun 18 22:30:52 2013 +0100
summary:
  Changes to readline.py to pass test_readline.py
test_readline is skipped when regression tests run, as stdin is not then a terminal,
but when run manually it would fail. This was discovered during work on
the revised JLineConsole but is independent of it.

files:
  Lib/readline.py |  14 ++++++++++++--
  1 files changed, 12 insertions(+), 2 deletions(-)


diff --git a/Lib/readline.py b/Lib/readline.py
--- a/Lib/readline.py
+++ b/Lib/readline.py
@@ -94,7 +94,7 @@
     _reader.history.clear()
 
 def add_history(line):
-    _reader.addToHistory(line)
+    _reader.history.addToHistory(line)
 
 def get_history_length():
     return _reader.history.maxSize
@@ -106,7 +106,11 @@
     return len(_reader.history.historyList)
 
 def get_history_item(index):
-    return _reader.history.historyList[index]
+    # JLine indexes from 0 while readline indexes from 1 (at least in test_readline)
+    if index>0:
+        return _reader.history.historyList[index-1]
+    else:
+        return None
 
 def remove_history_item(pos):
     if _history_list:
@@ -114,6 +118,12 @@
     else:
         warn("Cannot remove history item at position: %s" % (pos,), SecurityWarning, stacklevel=2)
 
+def replace_history_item(pos, line):
+    if _history_list:
+        _history_list.set(pos, line)
+    else:
+        warn("Cannot replace history item at position: %s" % (pos,), SecurityWarning, stacklevel=2)
+
 def redisplay():
     _reader.redrawLine()
 

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list