diff options
author | Victor Stinner <vstinner@python.org> | 2024-11-26 09:21:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-26 09:21:57 (GMT) |
commit | 3c7a90a83146dc6e55f6f9ecd9af0bf9682f98a6 (patch) | |
tree | 97ecc5a9b358baa268e8939aed959d10c4a3d140 /Lib/_pyrepl | |
parent | f46d8475749a0eadbc1f37079906a8e1ed5d56dc (diff) | |
download | cpython-3c7a90a83146dc6e55f6f9ecd9af0bf9682f98a6.zip cpython-3c7a90a83146dc6e55f6f9ecd9af0bf9682f98a6.tar.gz cpython-3c7a90a83146dc6e55f6f9ecd9af0bf9682f98a6.tar.bz2 |
gh-122273: Support PyREPL history on Windows (#127141)
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
Diffstat (limited to 'Lib/_pyrepl')
-rw-r--r-- | Lib/_pyrepl/readline.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/_pyrepl/readline.py b/Lib/_pyrepl/readline.py index 5e1d308..888185e 100644 --- a/Lib/_pyrepl/readline.py +++ b/Lib/_pyrepl/readline.py @@ -450,7 +450,9 @@ class _ReadlineWrapper: def write_history_file(self, filename: str = gethistoryfile()) -> None: maxlength = self.saved_history_length history = self.get_reader().get_trimmed_history(maxlength) - with open(os.path.expanduser(filename), "w", encoding="utf-8") as f: + f = open(os.path.expanduser(filename), "w", + encoding="utf-8", newline="\n") + with f: for entry in history: entry = entry.replace("\n", "\r\n") # multiline history support f.write(entry + "\n") |