From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 2 Jul 2020 11:02:16 +0000 (-0700) Subject: bpo-41193: Ignore OSError in readline write_history() (GH-21279) X-Git-Tag: v3.9.0b4~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0b4c87ef8f88a4c4c325e964fa4919cef3997605;p=thirdparty%2FPython%2Fcpython.git 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 0ab917e07ed64c6bfde6f6e791f9b28acc97b510) Co-authored-by: Victor Stinner --- diff --git a/Lib/site.py b/Lib/site.py index e981a142088f..9e617afb00f1 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -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) 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 000000000000..8807d9c21feb --- /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`.