Skip to content

Commit 53d2b71

Browse files
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. (cherry picked from commit 0ab917e) Co-authored-by: Victor Stinner <[email protected]>
1 parent e738962 commit 53d2b71

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
@@ -444,9 +444,9 @@ def register_readline():
444444
def write_history():
445445
try:
446446
readline.write_history_file(history)
447-
except (FileNotFoundError, PermissionError):
448-
# home directory does not exist or is not writable
449-
# https://bugs.python.org/issue19891
447+
except OSError:
448+
# bpo-19891, bpo-41193: Home directory does not exist
449+
# or is not writable, or the filesystem is read-only.
450450
pass
451451

452452
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)