[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Catching a non-Exception object (KeyboardInterrupt

Michael Goerz

2/4/2008 1:54:00 PM

Hi,

when I try to catch ctrl+c with

except KeyboardInterrupt:

pychecker tells me

Catching a non-Exception object (KeyboardInterrupt)

It works fine, but the message indicates that it's not completely clean.
How should I write the exception correctly?

Thanks,
Michael
3 Answers

Hrvoje Niksic

2/4/2008 2:08:00 PM

0

Michael Goerz <answer654@8439.e4ward.com> writes:

> when I try to catch ctrl+c with
>
> except KeyboardInterrupt:
>
> pychecker tells me
>
> Catching a non-Exception object (KeyboardInterrupt)

Looks like a pychecker bug. It might be confused by KeyboardInterrupt
being derived not from Exception, but from BaseException.

Duncan Booth

2/4/2008 2:28:00 PM

0

Hrvoje Niksic <hniksic@xemacs.org> wrote:

> Michael Goerz <answer654@8439.e4ward.com> writes:
>
>> when I try to catch ctrl+c with
>>
>> except KeyboardInterrupt:
>>
>> pychecker tells me
>>
>> Catching a non-Exception object (KeyboardInterrupt)
>
> Looks like a pychecker bug. It might be confused by KeyboardInterrupt
> being derived not from Exception, but from BaseException.
>

There's a patch for this see:
https://thomas.apestaart.org/thomas/trac/changeset/938?format=diff&a...
but it looks like pychecker isn't being maintained because nothing has
changed for more than 2 years.

Gabriel Genellina

2/4/2008 2:34:00 PM

0

En Mon, 04 Feb 2008 11:53:52 -0200, Michael Goerz
<answer654@8439.e4ward.com> escribi�:

> when I try to catch ctrl+c with
>
> except KeyboardInterrupt:
>
> pychecker tells me
>
> Catching a non-Exception object (KeyboardInterrupt)
>
> It works fine, but the message indicates that it's not completely clean.
> How should I write the exception correctly?

Your code is right; the latest official release of pychecker doesn't
support Python 2.5.
The exception hierarchy has changed a little, now you have BaseException
-> Exception -> all standard exceptions. KeyboardInterrupt and SystemExit
are now direct subclasses of BaseException, not of Exception.
According to the changelog [1] the development version does support 2.5

[1]
http://pychecker.cvs.sourceforge.net/pychecker/pychecker/CHANGELOG?v...

--
Gabriel Genellina