From 167c33672500502c979eeb0a9b4bd7cdd57c0efd Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Mon, 11 Jan 2016 23:30:15 +0200 Subject: #25991: fix readline example to limit history size. Patch by Daniel Dye. --- Doc/library/readline.rst | 3 +++ 1 file changed, 3 insertions(+) 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) -- cgit v0.12