cpython: 005cab4f5629 (original) (raw)

Mercurial > cpython

changeset 102016:005cab4f5629 3.5

Issue #16182: set_pre_input_hook() may not exist; document, and update test [#16182]

Martin Panter vadmium+py@gmail.com
date Tue, 14 Jun 2016 08:45:43 +0000
parents 376a379f12fe
children c4dd384ee3fa 0885477fecfd
files Doc/library/readline.rst Lib/test/test_readline.py
diffstat 2 files changed, 20 insertions(+), 9 deletions(-)[+] [-] Doc/library/readline.rst 7 Lib/test/test_readline.py 22

line wrap: on

line diff

--- a/Doc/library/readline.rst +++ b/Doc/library/readline.rst @@ -104,7 +104,9 @@ The following functions operate on a his Append the last nelements items of history to a file. The default filename is :file:~/.history. The file must already exist. This calls

@@ -185,7 +187,8 @@ Startup hooks be used as the new hook function; if omitted or None, any function already installed is removed. The hook is called with no arguments after the first prompt has been printed and just before

Completion

--- a/Lib/test/test_readline.py +++ b/Lib/test/test_readline.py @@ -129,24 +129,32 @@ class TestReadline(unittest.TestCase): script = r"""import readline -if readline.doc and "libedit" in readline.doc: +is_editline = readline.doc and "libedit" in readline.doc +inserted = "[\xEFnserted]" +macro = "|t\xEB[after]" +set_pre_input_hook = getattr(readline, "set_pre_input_hook", None) +if is_editline or not set_pre_input_hook:

+ +if is_editline: readline.parse_and_bind(r'bind ^B ed-prev-char') readline.parse_and_bind(r'bind "\t" rl_complete')

else: readline.parse_and_bind(r'Control-b: backward-char') readline.parse_and_bind(r'"\t": complete') readline.parse_and_bind(r'set disable-completion off') readline.parse_and_bind(r'set show-all-if-ambiguous off') readline.parse_and_bind(r'set show-all-if-unmodified off')

def pre_input_hook():

def completer(text, state): if text == "t\xEB":