|
|
86baa9 |
From 9fd415c73d0b70c1afadd5694269bf429fbd1aa2 Mon Sep 17 00:00:00 2001
|
|
|
86baa9 |
From: Sergey Orlov <sorlov@redhat.com>
|
|
|
86baa9 |
Date: Thu, 25 Apr 2019 18:30:24 +0200
|
|
|
86baa9 |
Subject: [PATCH] ipa console: catch proper exception when history file can not
|
|
|
86baa9 |
be open
|
|
|
86baa9 |
|
|
|
86baa9 |
When history file could not be open we were catching OSError. This worked
|
|
|
86baa9 |
for python3, as it raises FileNotFoundError, which is a subclass of
|
|
|
86baa9 |
OSError. But in python2 IOError is raised when file does not exist and
|
|
|
86baa9 |
as this exception was not catched, "ipa conosle" command was crashing.
|
|
|
86baa9 |
As far as in pyton3 IOError and OSError have been merged
|
|
|
86baa9 |
(OSError is IOError) we can safely catch only IOError.
|
|
|
86baa9 |
|
|
|
86baa9 |
Fixes: https://pagure.io/freeipa/issue/7922
|
|
|
86baa9 |
Reviewed-By: Christian Heimes <cheimes@redhat.com>
|
|
|
86baa9 |
---
|
|
|
86baa9 |
ipalib/cli.py | 4 ++--
|
|
|
86baa9 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
86baa9 |
|
|
|
86baa9 |
diff --git a/ipalib/cli.py b/ipalib/cli.py
|
|
|
86baa9 |
index 7b2af485d94e9f98df44b24489795c45d690956c..2c74a2aaa47a2471a232d81aa6acfafd7f9f930f 100644
|
|
|
86baa9 |
--- a/ipalib/cli.py
|
|
|
86baa9 |
+++ b/ipalib/cli.py
|
|
|
86baa9 |
@@ -969,7 +969,7 @@ class console(frontend.Command):
|
|
|
86baa9 |
history = os.path.join(api.env.dot_ipa, "console.history")
|
|
|
86baa9 |
try:
|
|
|
86baa9 |
readline.read_history_file(history)
|
|
|
86baa9 |
- except OSError:
|
|
|
86baa9 |
+ except IOError:
|
|
|
86baa9 |
pass
|
|
|
86baa9 |
|
|
|
86baa9 |
def save_history():
|
|
|
86baa9 |
@@ -979,7 +979,7 @@ class console(frontend.Command):
|
|
|
86baa9 |
readline.set_history_length(50)
|
|
|
86baa9 |
try:
|
|
|
86baa9 |
readline.write_history_file(history)
|
|
|
86baa9 |
- except OSError:
|
|
|
86baa9 |
+ except IOError:
|
|
|
86baa9 |
logger.exception("Unable to store history %s", history)
|
|
|
86baa9 |
|
|
|
86baa9 |
atexit.register(save_history)
|
|
|
86baa9 |
--
|
|
|
86baa9 |
2.20.1
|
|
|
86baa9 |
|