Annoying message when interrupting python scripts

John Machin sjmachin at lexicon.net
Tue Jun 17 22:56:49 EDT 2008


On Jun 18, 12:26 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> John Machin <sjmac... at lexicon.net> writes:
> > On Jun 18, 12:51 am, geoffbache <geoff.ba... at jeppesen.com> wrote:
> > [snip]
> > > Is this a bug? I couldn't find any code, but I imagine something like
> > > try:
> > >      import site
> > > except:
> > >      sys.stderr.write("import site failed; use -v for traceback\n")
>
> > > which should surely allow a KeyboardInterrupt exception through?
>
> > Surely?? A bare "except" catches *all* remaining uncaught exceptions.
>
> I parsed that "should" as "this should be changed".
>
> > Allowing a KeyboardInterrupt exception through would require:
> >    except KeyboardInterrupt:
> >       pass
>
> Actually, to allow it through would require re-raising it:
>
>     except KeyboardInterrupt:
>         raise
>
> Yes, I think that's what Geoff is saying "should" be done :-)

And all of what he was saying or not saying or should have been saying
was prefaced by "I imagine" anyway :-)



More information about the Python-list mailing list