[Python-checkins] bpo-41193: Ignore OSError in readline write_history() (GH-21279)

Victor Stinner webhook-mailer at python.org
Thu Jul 2 06:43:33 EDT 2020


https://github.com/python/cpython/commit/0ab917e07ed64c6bfde6f6e791f9b28acc97b510
commit: 0ab917e07ed64c6bfde6f6e791f9b28acc97b510
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-07-02T12:43:25+02:00
summary:

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.

files:
A Misc/NEWS.d/next/Library/2020-07-02-11-53-45.bpo-41193.8-Tnql.rst
M Lib/site.py

diff --git a/Lib/site.py b/Lib/site.py
index 544306cd40e32..8979365cafc37 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -462,9 +462,9 @@ def register_readline():
             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)
diff --git a/Misc/NEWS.d/next/Library/2020-07-02-11-53-45.bpo-41193.8-Tnql.rst b/Misc/NEWS.d/next/Library/2020-07-02-11-53-45.bpo-41193.8-Tnql.rst
new file mode 100644
index 0000000000000..8807d9c21febd
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-07-02-11-53-45.bpo-41193.8-Tnql.rst
@@ -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`.



More information about the Python-checkins mailing list