diff --git a/Lib/site.py b/Lib/site.py index 9da8b6724e1cec..79930268e25097 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -578,10 +578,10 @@ def register_readline(): def write_history(): try: readline_module.write_history_file(history) - except (FileNotFoundError, PermissionError): + except (FileNotFoundError, PermissionError, OSError) as e: # home directory does not exist or is not writable # https://bugs.python.org/issue19891 - pass + _warn(f'failed to open the history file for writing: {e}', RuntimeWarning) atexit.register(write_history) diff --git a/Misc/NEWS.d/next/Library/2024-12-19-07-27-52.gh-issue-128066.85NlMB.rst b/Misc/NEWS.d/next/Library/2024-12-19-07-27-52.gh-issue-128066.85NlMB.rst new file mode 100644 index 00000000000000..eeae8f1fc666c8 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-12-19-07-27-52.gh-issue-128066.85NlMB.rst @@ -0,0 +1 @@ +Fixed pyrepl history saving on read-only file systems.