URL: https://github.com/freeipa/freeipa/pull/3083 Author: tiran Title: #3083: [Backport][ipa-4-6] ipa console: catch proper exception when history file can not be open Action: opened
PR body: """ This PR was opened automatically because PR #3076 was pushed to ipa-4-7 and backport to ipa-4-6 is required. """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/3083/head:pr3083 git checkout pr3083
From f5456a652903222018684ffe97d48ff6fa4d6ff4 Mon Sep 17 00:00:00 2001 From: Sergey Orlov <sor...@redhat.com> Date: Thu, 25 Apr 2019 18:30:24 +0200 Subject: [PATCH] ipa console: catch proper exception when history file can not be open When history file could not be open we were catching OSError. This worked for python3, as it raises FileNotFoundError, which is a subclass of OSError. But in python2 IOError is raised when file does not exist and as this exception was not catched, "ipa conosle" command was crashing. As far as in pyton3 IOError and OSError have been merged (OSError is IOError) we can safely catch only IOError. Fixes: https://pagure.io/freeipa/issue/7922 --- ipalib/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipalib/cli.py b/ipalib/cli.py index 7b2af485d9..2c74a2aaa4 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -969,7 +969,7 @@ def _setup_tab_completion(self, local): history = os.path.join(api.env.dot_ipa, "console.history") try: readline.read_history_file(history) - except OSError: + except IOError: pass def save_history(): @@ -979,7 +979,7 @@ def save_history(): readline.set_history_length(50) try: readline.write_history_file(history) - except OSError: + except IOError: logger.exception("Unable to store history %s", history) atexit.register(save_history)
_______________________________________________ FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org