[lug] Python: Unable to catch subprocess error

Jed S. Baer blug at jbaer.cotse.net
Sat Mar 10 09:34:59 MST 2018


On Sat, 10 Mar 2018 06:47:49 -0700
Rob Nagler wrote:

> On Fri, Mar 9, 2018 at 8:12 PM, Jed S. Baer wrote:
> 
> > My understanding is that "except", by itself, is a catch-all. This
> > would seem to be good practice in an error handler. It catches
> > anything not explicitly handled.
> 
> It's just bad practice afaict. Here's some discussion:
> 
> https://stackoverflow.com/a/4990739

But note, "Unless you re-raise the exception right away". Which makes
perfect sense. At least to me. But then I have certain expectations for
error trap behavior. What happens when the code falls of the end of the
try block without handling an exception? Experimentation (just now)
indicates that the exception is passed through (i.e. re-raised). But in
reading various docs, this isn't stated. e.g.
https://www.tutorialspoint.com/python/python_exceptions.htm
though to me, it would seem so easy to include such a sentence, that the
lack of it implies that it is not the case.

> Python is inconsistent in that way,

Oh joy! :)

> Note that you'll want to "future proof" your Python.

I've read about that stuff. Still haven't decided where I stand on it.


More information about the LUG mailing list