Catching a non-Exception object (KeyboardInterrupt)

M

Michael Goerz

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
 
H

Hrvoje Niksic

Michael Goerz said:
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.
 
G

Gabriel Genellina

En Mon, 04 Feb 2008 11:53:52 -0200, Michael Goerz
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?view=markup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top