policycoreutils/0007-python-remove-IOError-in-certain-cases.patch

58 lines
1.9 KiB
Diff
Raw Normal View History

From ebb4a170c024d4bf0d2773b93d916e77a87393d9 Mon Sep 17 00:00:00 2001
From: Elijah Conners <business@elijahpepe.com>
Date: Wed, 15 Jun 2022 22:13:31 -0700
Subject: [PATCH] python: remove IOError in certain cases
Content-type: text/plain
In certain cases, IOError caused the much more general exception OSError
to be unreachable.
Signed-off-by: Elijah Conners <business@elijahpepe.com>
Acked-by: Petr Lautrbach <plautrba@redhat.com>
---
python/semanage/semanage | 7 ++-----
sandbox/sandbox | 2 --
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/python/semanage/semanage b/python/semanage/semanage
index 4e8d64d6863a..10ab3fa67d7f 100644
--- a/python/semanage/semanage
+++ b/python/semanage/semanage
@@ -971,8 +971,8 @@ def do_parser():
devnull = os.open(os.devnull, os.O_WRONLY)
os.dup2(devnull, sys.stdout.fileno())
sys.exit(1)
- except IOError as e:
- sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e)))
+ except OSError as e:
+ sys.stderr.write("%s: %s\n" % (e.__class__.__name__, e.args[1]))
sys.exit(1)
except KeyboardInterrupt:
sys.exit(0)
@@ -982,9 +982,6 @@ def do_parser():
except KeyError as e:
sys.stderr.write("%s: %s\n" % (e.__class__.__name__, e.args[0]))
sys.exit(1)
- except OSError as e:
- sys.stderr.write("%s: %s\n" % (e.__class__.__name__, e.args[1]))
- sys.exit(1)
except RuntimeError as e:
sys.stderr.write("%s: %s\n" % (e.__class__.__name__, e.args[0]))
sys.exit(1)
diff --git a/sandbox/sandbox b/sandbox/sandbox
index 789621e136da..ffac70232875 100644
--- a/sandbox/sandbox
+++ b/sandbox/sandbox
@@ -534,8 +534,6 @@ if __name__ == '__main__':
error_exit(error.args[0])
except KeyError as error:
error_exit(_("Invalid value %s") % error.args[0])
- except IOError as error:
- error_exit(error)
except KeyboardInterrupt:
rc = 0
--
2.38.1