From ad74a92e2d937254731de64d92e5b942f678b62c Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Fri, 16 Aug 2019 19:03:34 -0400 Subject: [PATCH] Avoid a crash when we can't access a history file --- NEWS.rst | 1 + hy/completer.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 36a681e..72e3581 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -21,6 +21,7 @@ Bug Fixes * Statements in the second argument of `assert` are now executed. * Fixed the expression of a while loop that contains statements being compiled twice. * `hy2py` can now handle format strings. +* Fixed crashes from inaccessible history files. 0.17.0 ============================== diff --git a/hy/completer.py b/hy/completer.py index b1969c1..34308ba 100644 --- a/hy/completer.py +++ b/hy/completer.py @@ -123,7 +123,7 @@ def completion(completer=None): try: readline.read_history_file(history) except IOError: - open(history, 'a').close() + pass readline.parse_and_bind(readline_bind) @@ -131,4 +131,7 @@ def completion(completer=None): yield finally: if docomplete: - readline.write_history_file(history) + try: + readline.write_history_file(history) + except IOError: + pass