SELinux Security Module development
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: Elijah Conners <business@elijahpepe.com>,
	selinux <selinux@vger.kernel.org>
Subject: Re: [PATCH] python: remove IOError in certain cases
Date: Mon, 20 Jun 2022 20:04:17 +0200	[thread overview]
Message-ID: <87letrrz32.fsf@redhat.com> (raw)
In-Reply-To: <1816aee4f80.1026d4b311254470.8507588530121880177@elijahpepe.com>

Elijah Conners <business@elijahpepe.com> writes:

> In certain cases, IOError caused the much more general exception OSError
> to be unreachable.
>
> Signed-off-by: Elijah Conners <business@elijahpepe.com>

Could you please provide more details about the certain cases,
preferably with a reproducer?

Thanks,

Petr



> ---
>  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


  reply	other threads:[~2022-06-20 18:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16  5:13 [PATCH] python: remove IOError in certain cases Elijah Conners
2022-06-20 18:04 ` Petr Lautrbach [this message]
2022-06-20 22:21   ` Elijah Conners
2022-07-19  9:07 ` Petr Lautrbach
2022-07-19  9:10   ` Petr Lautrbach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87letrrz32.fsf@redhat.com \
    --to=plautrba@redhat.com \
    --cc=business@elijahpepe.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox