Author infinitewarp
Recipients bazwal, docs@python, infinitewarp
Date 2017-10-09.02:56:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I ran into the same bug in the documentation recently. I've opened a pull request here that fixes it:

As I was trying to figure out why the example was broken, I wrote up a little more context to explain the current behavior and the fix:

In the "Example" section, the second example that "supports concurrent interactive sessions, by only appending the new history" will actually *never* write any lines to a custom history file. This is conveniently masked by the fact that the file path used in the example code also happens to be the default path that readline automatically writes history to, but if you specify *any* other file path, you will see that the new file is created but never has any content written to it.

The problem in this example is the use of `get_history_length` to get "previous" and "current" history lengths for determining how many lines to append to the file. Both calls to `get_history_length` always return `-1` here. Thus, when `append_history_file` is called, it always receives a first argument of `0` (because `-1 - -1 == 0`), resulting in zero lines written to the file.

Instead of `get_history_length`, the example code *should* call `get_current_history_length`. Swapping that function call makes the example behave as expected, appending new lines to the file.
Date User Action Args
2017-10-09 02:56:45infinitewarpsetrecipients: + infinitewarp, bazwal, docs@python
2017-10-09 02:56:45infinitewarpsetmessageid: <>
2017-10-09 02:56:45infinitewarplinkissue31537 messages
2017-10-09 02:56:45infinitewarpcreate