TERM='xterm-256color')
self.assertEqual(stdout, b'')
+ auto_history_script = """\
+import readline
+readline.set_auto_history({})
+input()
+print("History length:", readline.get_current_history_length())
+"""
+
+ def test_auto_history_enabled(self):
+ output = run_pty(self.auto_history_script.format(True))
+ self.assertIn(b"History length: 1\r\n", output)
+
+ def test_auto_history_disabled(self):
+ output = run_pty(self.auto_history_script.format(False))
+ self.assertIn(b"History length: 0\r\n", output)
+
+ def test_nonascii(self):
+ try:
+ readline.add_history("\xEB\xEF")
+ except UnicodeEncodeError as err:
+ self.skipTest("Locale cannot encode test data: " + format(err))
+
+ script = r"""import readline
+
+ if readline.__doc__ and "libedit" in readline.__doc__:
+ readline.parse_and_bind(r'bind ^B ed-prev-char')
+ readline.parse_and_bind(r'bind "\t" rl_complete')
+ readline.parse_and_bind('bind -s ^A "|t\xEB[after]"')
+ 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')
+ readline.parse_and_bind('Control-a: "|t\xEB[after]"')
+
+ def pre_input_hook():
+ readline.insert_text("[\xEFnserted]")
+ readline.redisplay()
+ readline.set_pre_input_hook(pre_input_hook)
+
+ def completer(text, state):
+ if text == "t\xEB":
+ 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"
+ if state == 1:
+ return "t\xEBxt"
+ if text == "t\xEBx" and state == 0:
+ return "t\xEBxt"
+ return None
+ readline.set_completer(completer)
+
+ def display(substitution, matches, longest_match_length):
+ print("substitution", ascii(substitution))
+ print("matches", ascii(matches))
+ readline.set_completion_display_matches_hook(display)
+
+ print("result", ascii(input()))
+ print("history", ascii(readline.get_history_item(1)))
+ """
+
+ input = b"\x01" # Ctrl-A, expands to "|t\xEB[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"\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)
+ self.assertIn(b"indexes 11 13\r\n", output)
+ 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"result " + expected + b"\r\n", output)
+ self.assertIn(b"history " + expected + b"\r\n", output)
+
def run_pty(script, input=b"dummy input\r"):
pty = import_module('pty')
Python News
+++++++++++
-What's New in Python 3.5.3 release candidate 1?
-===============================================
-
-Release date: TBA
+What's New in Python 3.6.0 alpha 3
+==================================
-Core and Builtins
------------------
+*Release date: XXXX-XX-XX*
--------
+ Library
+++++++++
+
+ - Issue #16182: Fix various functions in the "readline" module to use the
+ locale encoding, and fix get_begidx() and get_endidx() to return code point
+ indexes.
+
+IDLE
+++++
-What's New in Python 3.5.2 final?
-=================================
-
-Release date: 2016-06-26
-
-Core and Builtins
------------------
-
-Library
--------
+- Issue #27310: Fix IDLE.app failure to launch on OS X due to vestigial import.
-What's New in Python 3.5.2 release candidate 1?
-===============================================
+What's New in Python 3.6.0 alpha 2
+==================================
-Release date: 2016-06-12
+*Release date: XXXX-XX-XX*
Core and Builtins
-----------------
{"get_endidx", get_endidx, METH_NOARGS, doc_get_endidx},
{"set_completer_delims", set_completer_delims,
- METH_VARARGS, doc_set_completer_delims},
+ METH_O, doc_set_completer_delims},
+ {"set_auto_history", py_set_auto_history, METH_VARARGS, doc_set_auto_history},
- {"add_history", py_add_history, METH_VARARGS, doc_add_history},
+ {"add_history", py_add_history, METH_O, doc_add_history},
{"remove_history_item", py_remove_history, METH_VARARGS, doc_remove_history},
{"replace_history_item", py_replace_history, METH_VARARGS, doc_replace_history},
{"get_completer_delims", get_completer_delims,