hello everybody,
Currently working on making Pylint py3k compatible, I wonder about
'W0703': ('Catch "Exception"',
'Used when an except catches Exception instances.'),
It seems to me that it was justified for for py < 2.5, where we have:
>>> Exception.__bases__
()
>>> SystemExit.__bases__
(<class exceptions.Exception at 0x7fed405f50b0>,)
hence catching Exception could catch a SystemExit and is as bad as :
"except:"
But in Py >= 2.5,
>>> Exception.__bases__
(<type 'exceptions.BaseException'>,)
>>> SystemExit.__bases__
(<type 'exceptions.BaseException'>,)
Hence, we won't catch SystemExit and not even KeyboardInterrupt and
GeneratorExit :
http://docs.python.org/library/exceptions.html#exception-hierarchy
Furthermore, py3k removes the StandardError and 2to3lib
replaces it by Exception.
So, to be consistent with py3k, either we should also warn about catching
StandardError, or we should not warn at all.
And should we warn about catching BaseException?
I think that catching BaseException must be intended, so to warn here
seems strange to me.
Any opinions on the subject ?
--
Emile Anclin <[email protected]>
http://www.logilab.fr/ http://www.logilab.org/
Informatique scientifique & et gestion de connaissances
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects