From afa at codespeak.net Mon Feb 14 23:06:30 2011 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 14 Feb 2011 23:06:30 +0100 (CET) Subject: [pyrepl-checkins] r80344 - pyrepl/trunk/pyrepl/pyrepl Message-ID: <20110214220630.39991282B90@codespeak.net> 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 From afa at codespeak.net Tue Feb 15 00:16:36 2011 From: afa at codespeak.net (afa at codespeak.net) Date: Tue, 15 Feb 2011 00:16:36 +0100 (CET) Subject: [pyrepl-checkins] r80345 - pyrepl/trunk/pyrepl/pyrepl Message-ID: <20110214231636.A939F282B90@codespeak.net> Author: afa Date: Tue Feb 15 00:16:35 2011 New Revision: 80345 Modified: pyrepl/trunk/pyrepl/pyrepl/unix_eventqueue.py Log: Fix the termios module: now RPython termios raises OSError to better convey the errno attribute. Also fix a failure with readline when stdin is not a tty. Modified: pyrepl/trunk/pyrepl/pyrepl/unix_eventqueue.py ============================================================================== --- pyrepl/trunk/pyrepl/pyrepl/unix_eventqueue.py (original) +++ pyrepl/trunk/pyrepl/pyrepl/unix_eventqueue.py Tue Feb 15 00:16:35 2011 @@ -25,6 +25,7 @@ from pyrepl.console import Event from pyrepl import curses from termios import tcgetattr, VERASE +import os _keynames = { "delete" : "kdch1", @@ -52,7 +53,8 @@ keycode = curses.tigetstr(tiname) if keycode: our_keycodes[keycode] = unicode(key) - our_keycodes[tcgetattr(fd)[6][VERASE]] = u'backspace' + if os.isatty(fd): + our_keycodes[tcgetattr(fd)[6][VERASE]] = u'backspace' self.k = self.ck = keymap.compile_keymap(our_keycodes) self.events = [] self.buf = []