Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4d4f20

Browse files
committed
#25991: merge with 3.5.
2 parents 305e355 + 7c018aa commit d4d4f20

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Doc/library/readline.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ from the user's :envvar:`PYTHONSTARTUP` file. ::
209209
histfile = os.path.join(os.path.expanduser("~"), ".python_history")
210210
try:
211211
readline.read_history_file(histfile)
212+
# default history len is -1 (infinite), which may grow unruly
213+
readline.set_history_length(1000)
212214
except FileNotFoundError:
213215
pass
214216

@@ -234,6 +236,7 @@ sessions, by only appending the new history. ::
234236

235237
def save(prev_h_len, histfile):
236238
new_h_len = readline.get_history_length()
239+
readline.set_history_length(1000)
237240
readline.append_history_file(new_h_len - prev_h_len, histfile)
238241
atexit.register(save, h_len, histfile)
239242

@@ -261,4 +264,5 @@ support history save/restore. ::
261264
atexit.register(self.save_history, histfile)
262265

263266
def save_history(self, histfile):
267+
readline.set_history_length(1000)
264268
readline.write_history_file(histfile)

0 commit comments

Comments
 (0)