Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Lib/_pyrepl/readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,14 @@ def read_history_file(self, filename: str = gethistoryfile()) -> None:
def write_history_file(self, filename: str = gethistoryfile()) -> None:
maxlength = self.saved_history_length
history = self.get_reader().get_trimmed_history(maxlength)
f = open(os.path.expanduser(filename), "w",
encoding="utf-8", newline="\n")

try:
f = open(os.path.expanduser(filename), "w",
encoding="utf-8", newline="\n")
except OSError as e:
warnings.warn(f"failed to open the history file: {e}")
return

with f:
for entry in history:
entry = entry.replace("\n", "\r\n") # multiline history support
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed pyrepl history saving on read-only file systems.
Loading