All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] python: remove IOError in certain cases
@ 2022-06-16  5:13 Elijah Conners
  2022-06-20 18:04 ` Petr Lautrbach
  2022-07-19  9:07 ` Petr Lautrbach
  0 siblings, 2 replies; 5+ messages in thread
From: Elijah Conners @ 2022-06-16  5:13 UTC (permalink / raw)
  To: selinux

In certain cases, IOError caused the much more general exception OSError
to be unreachable.

Signed-off-by: Elijah Conners <business@elijahpepe.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 1d828128..c7a35fe4 100644
--- a/python/semanage/semanage
+++ b/python/semanage/semanage
@@ -970,8 +970,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)
@@ -981,9 +981,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 cd5709fb..1c9379ef 100644
--- a/sandbox/sandbox
+++ b/sandbox/sandbox
@@ -533,8 +533,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.29.2.windows.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-19  9:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-16  5:13 [PATCH] python: remove IOError in certain cases Elijah Conners
2022-06-20 18:04 ` Petr Lautrbach
2022-06-20 22:21   ` Elijah Conners
2022-07-19  9:07 ` Petr Lautrbach
2022-07-19  9:10   ` Petr Lautrbach

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.