Skip to content

Commit

Permalink
Fix/re-enable quoted_insert: use self.evt.data (#17)
Browse files Browse the repository at this point in the history
Reverts a59f338cc7b6c.

Fixes:

      File "/usr/lib/python3.7/cmd.py", line 126, in cmdloop
        line = input(self.prompt)
      File "…/src/pyrepl/pyrepl/readline.py", line 229, in raw_input
        ret = reader.readline(startup_hook=self.startup_hook)
      File "…/src/pyrepl/pyrepl/reader.py", line 605, in readline
        self.handle1()
      File "…/src/pyrepl/pyrepl/reader.py", line 588, in handle1
        self.do_cmd(cmd)
      File "…/src/pyrepl/pyrepl/reader.py", line 535, in do_cmd
        cmd.do()
      File "…/src/pyrepl/pyrepl/commands.py", line 373, in do
        r.insert((self.event + r.console.getpending().data) * r.get_arg())
    TypeError: can't concat str to bytearray
  • Loading branch information
blueyed authored Aug 15, 2019
1 parent f0b4b78 commit b3138ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions pyrepl/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,12 @@ def do(self):

class qIHelp(Command):
def do(self):
from .reader import disp_str

r = self.reader
r.insert((bytes(self.event) + r.console.getpending().data) * r.get_arg())
pending = r.console.getpending().data
disp = disp_str((self.event + pending))[0]
r.insert(disp * r.get_arg())
r.pop_input_trans()

from pyrepl import input
Expand All @@ -379,7 +383,7 @@ class QITrans(object):
def push(self, evt):
self.evt = evt
def get(self):
return ('qIHelp', self.evt.raw)
return ('qIHelp', self.evt.data)

class quoted_insert(Command):
kills_digit_arg = 0
Expand Down
4 changes: 4 additions & 0 deletions testing/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def get_event(self, block=1):
print("event", ev)
return Event(*ev)

def getpending(self):
"""Nothing pending, but do not return None here."""
return Event('key', '', b'')


class TestReader(Reader):
__test__ = False
Expand Down
2 changes: 1 addition & 1 deletion testing/test_wishes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def test_quoted_insert_repeat():
read_spec([
(('digit-arg', '3'), ['']),
(('quoted-insert', None), ['']),
(('self-insert', '\033'), ['^[^[^[']),
(('key', '\033'), ['^[^[^[']),
(('accept', None), None)])

0 comments on commit b3138ab

Please sign in to comment.