diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2016-01-11 21:30:15 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2016-01-11 21:30:15 (GMT) |
commit | 167c33672500502c979eeb0a9b4bd7cdd57c0efd (patch) | |
tree | 3f088187b4a899f2b02b6f80e5cc8055a6d546e6 /Doc/library | |
parent | 8da4023e2067a7f30c3e0fbfd55c3b6e2b59ab32 (diff) | |
download | cpython-167c33672500502c979eeb0a9b4bd7cdd57c0efd.zip cpython-167c33672500502c979eeb0a9b4bd7cdd57c0efd.tar.gz cpython-167c33672500502c979eeb0a9b4bd7cdd57c0efd.tar.bz2 |
#25991: fix readline example to limit history size. Patch by Daniel Dye.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/readline.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst index 64c61a2..4fc3e93 100644 --- a/Doc/library/readline.rst +++ b/Doc/library/readline.rst @@ -214,6 +214,8 @@ normally be executed automatically during interactive sessions from the user's histfile = os.path.join(os.path.expanduser("~"), ".pyhist") try: readline.read_history_file(histfile) + # default history len is -1 (infinite), which may grow unruly + readline.set_history_length(1000) except IOError: pass import atexit @@ -244,5 +246,6 @@ 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) |