summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-08-06 09:15:42 (GMT)
committerGitHub <noreply@github.com>2018-08-06 09:15:42 (GMT)
commite20d31cdb33bdfee68bce059f9a9c7ce71b035fe (patch)
tree17324896c31757551671b065c8c0bd871bd58a02
parent02c4eae35cd24ab71c12b5e61ec22e993ac4839b (diff)
downloadcpython-e20d31cdb33bdfee68bce059f9a9c7ce71b035fe.zip
cpython-e20d31cdb33bdfee68bce059f9a9c7ce71b035fe.tar.gz
cpython-e20d31cdb33bdfee68bce059f9a9c7ce71b035fe.tar.bz2
bpo-19891: Ignore error while writing history file (GH-8483)
(cherry picked from commit b2499669ef2e6dc9a2cdb49b4dc498e078167e26) Co-authored-by: Anthony Sottile <asottile@umich.edu>
-rw-r--r--Lib/site.py11
-rw-r--r--Misc/NEWS.d/next/Library/2018-07-26-08-45-49.bpo-19891.Y-3IiB.rst2
2 files changed, 12 insertions, 1 deletions
diff --git a/Lib/site.py b/Lib/site.py
index 1bd63cc..86ca2db 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -418,7 +418,16 @@ def enablerlcompleter():
readline.read_history_file(history)
except IOError:
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 0000000..18e10f5
--- /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.