[Python-checkins] bpo-19891: Ignore error while writing history file (GH-8483)
Miss Islington (bot)
webhook-mailer at python.org
Mon Aug 6 05:03:53 EDT 2018
https://github.com/python/cpython/commit/416f3435c536c5197f5c6a23504955cf717df200
commit: 416f3435c536c5197f5c6a23504955cf717df200
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-08-06T02:03:43-07:00
summary:
bpo-19891: Ignore error while writing history file (GH-8483)
(cherry picked from commit b2499669ef2e6dc9a2cdb49b4dc498e078167e26)
Co-authored-by: Anthony Sottile <asottile at umich.edu>
files:
A Misc/NEWS.d/next/Library/2018-07-26-08-45-49.bpo-19891.Y-3IiB.rst
M Lib/site.py
diff --git a/Lib/site.py b/Lib/site.py
index 4595244e2f5a..ffd132b389e1 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -439,7 +439,16 @@ def register_readline():
readline.read_history_file(history)
except OSError:
pass
- atexit.register(readline.write_history_file, history)
+
+ 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
+ pass
+
+ atexit.register(write_history)
sys.__interactivehook__ = register_readline
diff --git a/Misc/NEWS.d/next/Library/2018-07-26-08-45-49.bpo-19891.Y-3IiB.rst b/Misc/NEWS.d/next/Library/2018-07-26-08-45-49.bpo-19891.Y-3IiB.rst
new file mode 100644
index 000000000000..18e10f5aa3d6
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-07-26-08-45-49.bpo-19891.Y-3IiB.rst
@@ -0,0 +1,2 @@
+Ignore errors caused by missing / non-writable homedir while writing history
+during exit of an interactive session. Patch by Anthony Sottile.
More information about the Python-checkins
mailing list