mirror of
https://github.com/python/cpython.git
synced 2025-10-01 04:42:10 +00:00
bpo-31537: Update readline documentation example. (GH-3925) (GH-3948)
Change the code example from using `get_history_length` to `get_current_history_length`.
(cherry picked from commit eeb5ffd54e
)
This commit is contained in:
parent
a8ac71d15f
commit
10eb14e2c5
2 changed files with 4 additions and 2 deletions
|
@ -312,13 +312,13 @@ sessions, by only appending the new history. ::
|
||||||
|
|
||||||
try:
|
try:
|
||||||
readline.read_history_file(histfile)
|
readline.read_history_file(histfile)
|
||||||
h_len = readline.get_history_length()
|
h_len = readline.get_current_history_length()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
open(histfile, 'wb').close()
|
open(histfile, 'wb').close()
|
||||||
h_len = 0
|
h_len = 0
|
||||||
|
|
||||||
def save(prev_h_len, histfile):
|
def save(prev_h_len, histfile):
|
||||||
new_h_len = readline.get_history_length()
|
new_h_len = readline.get_current_history_length()
|
||||||
readline.set_history_length(1000)
|
readline.set_history_length(1000)
|
||||||
readline.append_history_file(new_h_len - prev_h_len, histfile)
|
readline.append_history_file(new_h_len - prev_h_len, histfile)
|
||||||
atexit.register(save, h_len, histfile)
|
atexit.register(save, h_len, histfile)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix incorrect usage of ``get_history_length`` in readline documentation
|
||||||
|
example code. Patch by Brad Smith.
|
Loading…
Add table
Add a link
Reference in a new issue