From: Ezio Melotti Date: Mon, 11 Jan 2016 21:30:15 +0000 (+0200) Subject: #25991: fix readline example to limit history size. Patch by Daniel Dye. X-Git-Tag: v2.7.12rc1~298 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=167c33672500502c979eeb0a9b4bd7cdd57c0efd;p=thirdparty%2FPython%2Fcpython.git #25991: fix readline example to limit history size. Patch by Daniel Dye. --- diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst index 64c61a27501c..4fc3e93e592c 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)