This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients martin.panter, xdegaye
Date 2016-12-18.07:24:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This is a breakdown of running the test script on my Linux setup (UTF-8 locale):

    Input echoed back (before Readline disables echo)
    Inserted by pre_input_hook()
    Inserted by the Ctrl+A macro
    Response to moving the cursor left of [after]
text \'t\\xeb\'\r\n
    Encoded completer(text=...) parameter for testing
line \'[\\xefnserted]|t\\xeb[after]\'\r\n
    get_line_buffer() result for testing
indexes 11 13\r\n
    get_begidx(), get_endidx()
    Rings terminal bell due to multiple possible completions
text . . . line . . . indexes . . .\r\n
    From second round of completer() calls due to second Tab input
substitution \'t\\xeb\'\r\n
matches [\'t\\xebnt\', \'t\\xebxt\']\r\n
    display() parameters
    Response to inserting “x”
    Completion of "t\xEBxt"
    Response to inputting Return
result \'[\\xefnserted]|t\\xebxt[after]\'\r\n
    input() function call return value
history \'[\\xefnserted]|t\\xebxt[after]\'\r\n
    Line as retrieved from history

The problem is that the Ctrl+A macro seems to have only inserted the two ASCII characters "|t" and has stopped at the non-ASCII character "\xEB". Everthing else relies on the macro working properly to get the right cursor positioning and completion text.

Xavier: If you run the following code in an interactive Python session, what does pressing $ print out?

import readline
readline.parse_and_bind('Control-a: "|t\xEB[after]"')
readline.parse_and_bind('"$": dump-macros')

For me, it prints this: (includes “te” with an umlaut)

\C-a outputs |të[after]

What locale encoding does Python use for you? The parse_and_bind() call should be encoding "\xEB" with PyUnicode_EncodeLocale(), and passing the resulting string to Readline. Then Readline is supposed to insert the string when we invoke the macro. Somewhere the string is getting truncated.
Date User Action Args
2016-12-18 07:24:25martin.pantersetrecipients: + martin.panter, xdegaye
2016-12-18 07:24:25martin.pantersetmessageid: <>
2016-12-18 07:24:25martin.panterlinkissue28997 messages
2016-12-18 07:24:24martin.pantercreate