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 0ab917e07e)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2020-07-02 04:02:16 -07:00 committed by GitHub
parent ecfecc2d6c
commit 0b4c87ef8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -453,9 +453,9 @@ def enablerlcompleter():
def write_history():
try:
readline.write_history_file(history)
except (FileNotFoundError, PermissionError):
# home directory does not exist or is not writable
# https://bugs.python.org/issue19891
except OSError:
# bpo-19891, bpo-41193: Home directory does not exist
# or is not writable, or the filesystem is read-only.
pass
atexit.register(write_history)

View File

@ -0,0 +1,4 @@
The ``write_history()`` atexit function of the readline completer now
ignores any :exc:`OSError` to ignore error if the filesystem is read-only,
instead of only ignoring :exc:`FileNotFoundError` and
:exc:`PermissionError`.