Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions Lib/_pyrepl/simple_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import sys
import code
import warnings
import errno

from .readline import _get_reader, multiline_input, append_history_file

Expand Down Expand Up @@ -153,6 +154,7 @@ def maybe_run_command(statement: str) -> bool:
append_history_file()
except (FileNotFoundError, PermissionError, OSError) as e:
warnings.warn(f"failed to open the history file for writing: {e}")

input_n += 1
except KeyboardInterrupt:
r = _get_reader()
Expand Down
8 changes: 7 additions & 1 deletion Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import _sitebuiltins
import _io as io
import stat
import errno

# Prefixes for site-packages; add additional prefixes like /usr/local here
PREFIXES = [sys.prefix, sys.exec_prefix]
Expand Down Expand Up @@ -578,10 +579,15 @@ def register_readline():
def write_history():
try:
readline_module.write_history_file(history)
except (FileNotFoundError, PermissionError):
except FileNotFoundError, PermissionError:
# home directory does not exist or is not writable
# https://bugs.python.org/issue19891
pass
except OSError:
if errno.EROFS:
pass # gh-128066: read-only file system
else:
raise

atexit.register(write_history)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixes an edge case where PyREPL improperly threw an error when Python is
invoked on a read only filesystem while trying to write history file
entries.
Loading