]> granicus.if.org Git - python/commitdiff
#25991: fix readline example to limit history size. Patch by Daniel Dye.
authorEzio Melotti <ezio.melotti@gmail.com>
Mon, 11 Jan 2016 21:30:15 +0000 (23:30 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Mon, 11 Jan 2016 21:30:15 +0000 (23:30 +0200)
Doc/library/readline.rst

index 64c61a27501c75a850a660536a9155d18afd4c09..4fc3e93e592cd52fdc90e502589ac780d97b424e 100644 (file)
@@ -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)