[pypy-commit] pyrepl py3ksupport: merge from default
RonnyPfannschmidt
noreply at buildbot.pypy.org
Sat Apr 28 16:55:06 CEST 2012
Author: Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
Branch: py3ksupport
Changeset: r170:71e5bead2693
Date: 2012-04-28 16:54 +0200
http://bitbucket.org/pypy/pyrepl/changeset/71e5bead2693/
Log: merge from default
diff --git a/pyrepl/reader.py b/pyrepl/reader.py
--- a/pyrepl/reader.py
+++ b/pyrepl/reader.py
@@ -50,9 +50,9 @@
# rewritten in C; it's not required though.
try:
raise ImportError # currently it's borked by the unicode support
-
+
from _pyrepl_utils import disp_str, init_unctrl_map
-
+
init_unctrl_map(_make_unctrl_map())
del init_unctrl_map
@@ -127,7 +127,7 @@
(r'\C-x\C-u', 'upcase-region'),
(r'\C-y', 'yank'),
(r'\C-z', 'suspend'),
-
+
(r'\M-b', 'backward-word'),
(r'\M-c', 'capitalize-word'),
(r'\M-d', 'kill-word'),
@@ -161,8 +161,8 @@
(r'\<delete>', 'delete'),
(r'\<backspace>', 'backspace'),
(r'\M-\<backspace>', 'backward-kill-word'),
- (r'\<end>', 'end'),
- (r'\<home>', 'home'),
+ (r'\<end>', 'end-of-line'), # was 'end'
+ (r'\<home>', 'beginning-of-line'), # was 'home'
(r'\<f1>', 'help'),
(r'\EOF', 'end'), # the entries in the terminfo database for xterms
(r'\EOH', 'home'), # seem to be wrong. this is a less than ideal
@@ -313,7 +313,7 @@
def process_prompt(self, prompt):
""" Process the prompt.
-
+
This means calculate the length of the prompt. The character \x01
and \x02 are used to bracket ANSI control sequences and need to be
excluded from the length calculation. So also a copy of the prompt
@@ -382,7 +382,7 @@
while p >= 0 and b[p] != '\n':
p -= 1
return p + 1
-
+
def eol(self, p=None):
"""Return the 0-based index of the line break following p most
immediately.
@@ -473,7 +473,7 @@
"""This function is called to allow post command cleanup."""
if getattr(cmd, "kills_digit_arg", 1):
if self.arg is not None:
- self.dirty = 1
+ self.dirty = 1
self.arg = None
def prepare(self):
@@ -592,13 +592,15 @@
def push_char(self, char):
self.console.push_char(char)
self.handle1(0)
-
- def readline(self, returns_unicode=False):
+
+ def readline(self, returns_unicode=False, startup_hook=None):
"""Read a line. The implementation of this method also shows
how to drive Reader if you want more control over the event
loop."""
self.prepare()
try:
+ if startup_hook is not None:
+ startup_hook()
self.refresh()
while not self.finished:
self.handle1()
diff --git a/pyrepl/readline.py b/pyrepl/readline.py
--- a/pyrepl/readline.py
+++ b/pyrepl/readline.py
@@ -193,10 +193,8 @@
reader = self.get_reader()
except _error:
return _old_raw_input(prompt)
- if self.startup_hook is not None:
- self.startup_hook()
reader.ps1 = prompt
- return reader.readline()
+ return reader.readline(reader, startup_hook=self.startup_hook)
def multiline_input(self, more_lines, ps1, ps2, returns_unicode=False):
"""Read an input on possibly multiple lines, asking for more
@@ -390,7 +388,7 @@
global _old_raw_input
if _old_raw_input is not None:
return # don't run _setup twice
-
+
try:
f_in = sys.stdin.fileno()
f_out = sys.stdout.fileno()
diff --git a/pyrepl/unix_console.py b/pyrepl/unix_console.py
--- a/pyrepl/unix_console.py
+++ b/pyrepl/unix_console.py
@@ -420,7 +420,12 @@
e.args[4] == 'unexpected end of data':
pass
else:
- raise
+ # was: "raise". But it crashes pyrepl, and by extension the
+ # pypy currently running, in which we are e.g. in the middle
+ # of some debugging session. Argh. Instead just print an
+ # error message to stderr and continue running, for now.
+ self.partial_char = ''
+ sys.stderr.write('\n%s: %s\n' % (e.__class__.__name__, e))
else:
self.partial_char = b''
self.event_queue.push(c)
More information about the pypy-commit
mailing list