mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-128066: Properly handle history file writes for RO fs on PyREPL (gh-134380)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
c7f8e706e1
commit
c91ad5da9d
3 changed files with 12 additions and 1 deletions
|
@ -75,6 +75,7 @@ import builtins
|
|||
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]
|
||||
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue