Commits

Amaury Forgeot d'Arc  committed fd34a1e

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.
"""

  • Participants
  • Parent commits cb22a06

Comments (0)

Files changed (1)

File pyrepl/readline.py

         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