diff -r 1756beed417c Lib/test/test_readline.py --- a/Lib/test/test_readline.py Sat Dec 17 09:19:11 2016 +0100 +++ b/Lib/test/test_readline.py Sun Dec 18 18:50:47 2016 +0100 @@ -138,7 +138,7 @@ def test_nonascii(self): try: - readline.add_history("\xEB\xEF") + readline.add_history("A\xEF") except UnicodeEncodeError as err: self.skipTest("Locale cannot encode test data: " + format(err)) @@ -146,7 +146,7 @@ is_editline = readline.__doc__ and "libedit" in readline.__doc__ inserted = "[\xEFnserted]" -macro = "|t\xEB[after]" +macro = "|tA[after]" set_pre_input_hook = getattr(readline, "set_pre_input_hook", None) if is_editline or not set_pre_input_hook: # The insert_line() call via pre_input_hook() does nothing with Editline, @@ -171,17 +171,22 @@ if set_pre_input_hook: set_pre_input_hook(pre_input_hook) +x = [] def completer(text, state): - if text == "t\xEB": + x.append('%s-%d' % (text, state)) + if text == "tA": if state == 0: print("text", ascii(text)) print("line", ascii(readline.get_line_buffer())) print("indexes", readline.get_begidx(), readline.get_endidx()) - return "t\xEBnt" + x.append('GOT 1') + return "tAnt" if state == 1: - return "t\xEBxt" - if text == "t\xEBx" and state == 0: - return "t\xEBxt" + x.append('GOT 2') + return "tAxt" + if text == "tAx" and state == 0: + x.append('GOT 3') + return "tAxt" return None readline.set_completer(completer) @@ -192,21 +197,23 @@ print("result", ascii(input())) print("history", ascii(readline.get_history_item(1))) +print('completer', x) """ - input = b"\x01" # Ctrl-A, expands to "|t\xEB[after]" + input = b"\x01" # Ctrl-A, expands to "|tA[after]" input += b"\x02" * len("[after]") # Move cursor back input += b"\t\t" # Display possible completions - input += b"x\t" # Complete "t\xEBx" -> "t\xEBxt" + input += b"x\t" # Complete "tAx" -> "tAxt" input += b"\r" output = run_pty(script, input) - self.assertIn(b"text 't\\xeb'\r\n", output) - self.assertIn(b"line '[\\xefnserted]|t\\xeb[after]'\r\n", output) + print(output) + self.assertIn(b"text 'tA'\r\n", output) + self.assertIn(b"line '[\\xefnserted]|tA[after]'\r\n", output) self.assertIn(b"indexes 11 13\r\n", output) if not is_editline and hasattr(readline, "set_pre_input_hook"): - self.assertIn(b"substitution 't\\xeb'\r\n", output) - self.assertIn(b"matches ['t\\xebnt', 't\\xebxt']\r\n", output) - expected = br"'[\xefnserted]|t\xebxt[after]'" + self.assertIn(b"substitution 'tA'\r\n", output) + self.assertIn(b"matches ['tAnt', 'tAxt']\r\n", output) + expected = br"'[\xefnserted]|tAxt[after]'" self.assertIn(b"result " + expected + b"\r\n", output) self.assertIn(b"history " + expected + b"\r\n", output)