1. Pypy
  2. Untitled project
  3. pypy
  4. Issues


Issue #2072 new

readline.parse_and_bind fails silently on 2.7

created an issue

In the command interpreter type: import readline readline.parse_and_bind('Control-tab: "import"')

Then type control-tab on the next line. readline should insert import. PyPy 2.7.9 (2.5.1+dfsg-1, Mar 27 2015, 19:45:43) doesn't.

There is an alternative syntax.
readline.parse_and_bind(r'"\C-\t": "import"')

This doesn't work either. Note that CPython Python 2.7.9 (default, Mar 1 2015, 12:57:24) has bugs over this also, but different ones.
readline.parse_and_bind(r'"\C-\t": "import"') in CPython does nothing. readline.parse_and_bind('Control-tab: "import"') works but if you then do readline.parse_and_bind('tab: "raise"')

both tab and control-tab will be set to insert "raise" by CPython. There seems to be no way to bind control-tab and tab to different things in CPython.

This bug was discovered by Steve D'Aprano in CPython 2.7. He will probably make a CPython bug report about it soon.

Comments (4)

  1. Armin Rigo

    See the definition of parse_and_bind() in PyPy, in lib_pypy/pyrepl/readline.py:

        def parse_and_bind(self, string):
            pass  # XXX we don't support parsing GNU-readline-style init files

    It could be documented somewhere...

  2. Armin Rigo

    It's not very clear, as it would annoy some people with PYTHONSTARTUP files that call it. It would start printing warnings all the time, which is sometimes worse than simply ignoring them---anyway it should be clear that our command-line is different than CPython's, if only because it supports multiline input.

    Documentation added in b488a7eacab3.

  3. Log in to comment