mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
gh-122273: Support PyREPL history on Windows (#127141)
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
This commit is contained in:
parent
f46d847574
commit
3c7a90a831
3 changed files with 40 additions and 20 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue