]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41193: Ignore OSError in readline write_history() (GH-21279)
authorVictor Stinner <vstinner@python.org>
Thu, 2 Jul 2020 10:43:25 +0000 (12:43 +0200)
committerGitHub <noreply@github.com>
Thu, 2 Jul 2020 10:43:25 +0000 (12:43 +0200)
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.

Lib/site.py
Misc/NEWS.d/next/Library/2020-07-02-11-53-45.bpo-41193.8-Tnql.rst [new file with mode: 0644]

index 544306cd40e3282ca5152b246a16da133576caee..8979365cafc37e78bc2ce97f3299968f9a0a3678 100644 (file)
@@ -462,9 +462,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)
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 (file)
index 0000000..8807d9c
--- /dev/null
@@ -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`.