Skip to content

Commit 0ab917e

Browse files
authored
bpo-41193: Ignore OSError in readline write_history() (GH-21279)
The write_history() atexit function of the readline completer now ignores any OSError to ignore error if the filesystem is read-only, instead of only ignoring FileNotFoundError and PermissionError.
1 parent 004e64e commit 0ab917e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Lib/site.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ def register_readline():
462462
def write_history():
463463
try:
464464
readline.write_history_file(history)
465-
except (FileNotFoundError, PermissionError):
466-
# home directory does not exist or is not writable
467-
# https://bugs.python.org/issue19891
465+
except OSError:
466+
# bpo-19891, bpo-41193: Home directory does not exist
467+
# or is not writable, or the filesystem is read-only.
468468
pass
469469

470470
atexit.register(write_history)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The ``write_history()`` atexit function of the readline completer now
2+
ignores any :exc:`OSError` to ignore error if the filesystem is read-only,
3+
instead of only ignoring :exc:`FileNotFoundError` and
4+
:exc:`PermissionError`.

0 commit comments

Comments
 (0)