r80344 - pyrepl/trunk/pyrepl/pyrepl

[email protected] Mon, 14 Feb 2011 23:06:30 +0100 (CET)
Newsgroups gmane.comp.python.pyrepl.checkins
Message-ID <[email protected]>
Author: afa
Date: Mon Feb 14 23:06:28 2011
New Revision: 80344

Modified:
   pyrepl/trunk/pyrepl/pyrepl/readline.py
Log:
Fix readline.py failures found by CPython test suite::
"""
 Currently there is one known API incompatibility:
 - 'get_history' has a 1-based index with GNU readline, and a 0-based
   index with libedit's emulation.
 - Note that replace_history and remove_history use a 0-based index
   with both implementation.
"""


Modified: pyrepl/trunk/pyrepl/pyrepl/readline.py
==============================================================================
--- pyrepl/trunk/pyrepl/pyrepl/readline.py	(original)
+++ pyrepl/trunk/pyrepl/pyrepl/readline.py	Mon Feb 14 23:06:28 2011
@@ -283,18 +283,18 @@
         else:
             return None        # blame readline.c for not raising
 
-    def remove_history_item(self, pos):
+    def remove_history_item(self, index):
         history = self.get_reader().history
-        if 1 <= index <= len(history):
-            del history[index-1]
+        if 0 <= index < len(history):
+            del history[index]
         else:
             raise ValueError("No history item at position %d" % index)
             # blame readline.c for raising ValueError
 
-    def replace_history_item(self, pos, line):
+    def replace_history_item(self, index, line):
         history = self.get_reader().history
-        if 1 <= index <= len(history):
-            history[index-1] = self._histline(line)
+        if 0 <= index < len(history):
+            history[index] = self._histline(line)
         else:
             raise ValueError("No history item at position %d" % index)
             # blame readline.c for raising ValueError