Skip to content

Commit b39e2cb

Browse files
merge from default
2 parents b369af9 + 8e5d9ef commit b39e2cb

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

pyrepl/reader.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def _make_unctrl_map():
5050
# rewritten in C; it's not required though.
5151
try:
5252
raise ImportError # currently it's borked by the unicode support
53-
53+
5454
from _pyrepl_utils import disp_str, init_unctrl_map
55-
55+
5656
init_unctrl_map(_make_unctrl_map())
5757

5858
del init_unctrl_map
@@ -127,7 +127,7 @@ def make_default_syntax_table():
127127
(r'\C-x\C-u', 'upcase-region'),
128128
(r'\C-y', 'yank'),
129129
(r'\C-z', 'suspend'),
130-
130+
131131
(r'\M-b', 'backward-word'),
132132
(r'\M-c', 'capitalize-word'),
133133
(r'\M-d', 'kill-word'),
@@ -161,8 +161,8 @@ def make_default_syntax_table():
161161
(r'\<delete>', 'delete'),
162162
(r'\<backspace>', 'backspace'),
163163
(r'\M-\<backspace>', 'backward-kill-word'),
164-
(r'\<end>', 'end'),
165-
(r'\<home>', 'home'),
164+
(r'\<end>', 'end-of-line'), # was 'end'
165+
(r'\<home>', 'beginning-of-line'), # was 'home'
166166
(r'\<f1>', 'help'),
167167
(r'\EOF', 'end'), # the entries in the terminfo database for xterms
168168
(r'\EOH', 'home'), # seem to be wrong. this is a less than ideal
@@ -313,7 +313,7 @@ def calc_screen(self):
313313

314314
def process_prompt(self, prompt):
315315
""" Process the prompt.
316-
316+
317317
This means calculate the length of the prompt. The character \x01
318318
and \x02 are used to bracket ANSI control sequences and need to be
319319
excluded from the length calculation. So also a copy of the prompt
@@ -382,7 +382,7 @@ def bol(self, p=None):
382382
while p >= 0 and b[p] != '\n':
383383
p -= 1
384384
return p + 1
385-
385+
386386
def eol(self, p=None):
387387
"""Return the 0-based index of the line break following p most
388388
immediately.
@@ -473,7 +473,7 @@ def after_command(self, cmd):
473473
"""This function is called to allow post command cleanup."""
474474
if getattr(cmd, "kills_digit_arg", 1):
475475
if self.arg is not None:
476-
self.dirty = 1
476+
self.dirty = 1
477477
self.arg = None
478478

479479
def prepare(self):
@@ -592,13 +592,15 @@ def handle1(self, block=1):
592592
def push_char(self, char):
593593
self.console.push_char(char)
594594
self.handle1(0)
595-
596-
def readline(self, returns_unicode=False):
595+
596+
def readline(self, returns_unicode=False, startup_hook=None):
597597
"""Read a line. The implementation of this method also shows
598598
how to drive Reader if you want more control over the event
599599
loop."""
600600
self.prepare()
601601
try:
602+
if startup_hook is not None:
603+
startup_hook()
602604
self.refresh()
603605
while not self.finished:
604606
self.handle1()

pyrepl/readline.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,8 @@ def raw_input(self, prompt=''):
193193
reader = self.get_reader()
194194
except _error:
195195
return _old_raw_input(prompt)
196-
if self.startup_hook is not None:
197-
self.startup_hook()
198196
reader.ps1 = prompt
199-
return reader.readline()
197+
return reader.readline(reader, startup_hook=self.startup_hook)
200198

201199
def multiline_input(self, more_lines, ps1, ps2, returns_unicode=False):
202200
"""Read an input on possibly multiple lines, asking for more
@@ -390,7 +388,7 @@ def _setup():
390388
global _old_raw_input
391389
if _old_raw_input is not None:
392390
return # don't run _setup twice
393-
391+
394392
try:
395393
f_in = sys.stdin.fileno()
396394
f_out = sys.stdout.fileno()

pyrepl/unix_console.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,12 @@ def push_char(self, char):
420420
e.args[4] == 'unexpected end of data':
421421
pass
422422
else:
423-
raise
423+
# was: "raise". But it crashes pyrepl, and by extension the
424+
# pypy currently running, in which we are e.g. in the middle
425+
# of some debugging session. Argh. Instead just print an
426+
# error message to stderr and continue running, for now.
427+
self.partial_char = ''
428+
sys.stderr.write('\n%s: %s\n' % (e.__class__.__name__, e))
424429
else:
425430
self.partial_char = b''
426431
self.event_queue.push(c)

0 commit comments

Comments
 (0)