]> granicus.if.org Git - python/commitdiff
bpo-31537: Update readline documentation example. (GH-3925)
authorBrad Smith <infinitewarp@users.noreply.github.com>
Tue, 10 Oct 2017 21:52:58 +0000 (17:52 -0400)
committerMariatta <Mariatta@users.noreply.github.com>
Tue, 10 Oct 2017 21:52:58 +0000 (14:52 -0700)
Change the code example from using `get_history_length` to `get_current_history_length`.

Doc/library/readline.rst
Misc/NEWS.d/next/Documentation/2017-10-08-23-02-14.bpo-31537.SiFNM8.rst [new file with mode: 0644]

index 54c54b461ce7e43ed006829a04b10dd5ad104601..837816e952ad566954c664b7b563df5615efbed8 100644 (file)
@@ -312,13 +312,13 @@ sessions, by only appending the new history. ::
 
    try:
        readline.read_history_file(histfile)
-       h_len = readline.get_history_length()
+       h_len = readline.get_current_history_length()
    except FileNotFoundError:
        open(histfile, 'wb').close()
        h_len = 0
 
    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.append_history_file(new_h_len - prev_h_len, histfile)
    atexit.register(save, h_len, histfile)
diff --git a/Misc/NEWS.d/next/Documentation/2017-10-08-23-02-14.bpo-31537.SiFNM8.rst b/Misc/NEWS.d/next/Documentation/2017-10-08-23-02-14.bpo-31537.SiFNM8.rst
new file mode 100644 (file)
index 0000000..9244d7e
--- /dev/null
@@ -0,0 +1,2 @@
+Fix incorrect usage of ``get_history_length`` in readline documentation
+example code. Patch by Brad Smith.