This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author keeely
Recipients keeely
Date 2021-11-22.13:51:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1637589082.36.0.67630471216.issue45870@roundup.psfhosted.org>
In-reply-to
Content
In the past this was worked around by installing a third-party module:
https://github.com/pyreadline/pyreadline

For Python 3.10, however this module doesn't work.  And pyreadline doesn't seem to be maintained anymore, so it's possible it won't get fixed.
https://github.com/pyreadline/pyreadline/issues/73

Consider the following code:

import cmd
import readline

open("history.txt", "w").write("first line\nsecond line\n")

readline.clear_history()
readline.read_history_file("history.txt")

class MyShell(cmd.Cmd):
    def __init__(self):
        super().__init__()

shell = MyShell()
shell.cmdloop()

This works fine on MacOs Python, also on Linux and on Windows prior to 3.10 with the readline module added.  It won't work going forward.

The Windows cmd implementation clearly uses readline or some compatible lib under the hood, so Python should make it available to developers.
History
Date User Action Args
2021-11-22 13:51:22keeelysetrecipients: + keeely
2021-11-22 13:51:22keeelysetmessageid: <1637589082.36.0.67630471216.issue45870@roundup.psfhosted.org>
2021-11-22 13:51:22keeelylinkissue45870 messages
2021-11-22 13:51:22keeelycreate