[Python-checkins] cpython (2.7): #25991: fix readline example to limit history size. Patch by Daniel Dye.
ezio.melotti
python-checkins at python.org
Mon Jan 11 16:31:53 EST 2016
https://hg.python.org/cpython/rev/9a2c891a4333
changeset: 99860:9a2c891a4333
branch: 2.7
parent: 99852:609226a23086
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Mon Jan 11 23:30:15 2016 +0200
summary:
#25991: fix readline example to limit history size. Patch by Daniel Dye.
files:
Doc/library/readline.rst | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst
--- a/Doc/library/readline.rst
+++ b/Doc/library/readline.rst
@@ -214,6 +214,8 @@
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 @@
atexit.register(self.save_history, histfile)
def save_history(self, histfile):
+ readline.set_history_length(1000)
readline.write_history_file(histfile)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list