diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2016-01-11 21:31:38 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2016-01-11 21:31:38 (GMT) |
commit | d4d4f20284a098f4bad2958d5a72cfd9033f8b08 (patch) | |
tree | 2e4669f1e2946d2c48b8d722474b9d548585abdf | |
parent | 305e3557e94735bbccde8ab2b881c93afa067e13 (diff) | |
parent | 7c018aa377bd25c34e09ad2e9e6740b2bc226493 (diff) | |
download | cpython-d4d4f20284a098f4bad2958d5a72cfd9033f8b08.zip cpython-d4d4f20284a098f4bad2958d5a72cfd9033f8b08.tar.gz cpython-d4d4f20284a098f4bad2958d5a72cfd9033f8b08.tar.bz2 |
#25991: merge with 3.5.
-rw-r--r-- | Doc/library/readline.rst | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst index b3d765c..5433405 100644 --- a/Doc/library/readline.rst +++ b/Doc/library/readline.rst @@ -209,6 +209,8 @@ from the user's :envvar:`PYTHONSTARTUP` file. :: histfile = os.path.join(os.path.expanduser("~"), ".python_history") try: readline.read_history_file(histfile) + # default history len is -1 (infinite), which may grow unruly + readline.set_history_length(1000) except FileNotFoundError: pass @@ -234,6 +236,7 @@ sessions, by only appending the new history. :: def save(prev_h_len, histfile): new_h_len = readline.get_history_length() + readline.set_history_length(1000) readline.append_history_file(new_h_len - prev_h_len, histfile) atexit.register(save, h_len, histfile) @@ -261,4 +264,5 @@ support history save/restore. :: atexit.register(self.save_history, histfile) def save_history(self, histfile): + readline.set_history_length(1000) readline.write_history_file(histfile) |