[issue2291] Raise a Py3K warning for catching non-BaseException exceptions

Alexander Belopolsky report at bugs.python.org
Mon Mar 17 22:40:14 CET 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

There is also a subtle bug in the issue2371 patch:
$ cat x.py
try:
    raise ValueError
except ((ValueError,),):
    pass

$ ./python -3 x.py
x.py:3: DeprecationWarning: catching classes that do not inherit from
BaseException is not allowed in 3.x.
  except ((ValueError,),):

I am not sure if it would be acceptable to move warnings to
PyErr_GivenExceptionMatches, but if not, the checking logic should
reproduce PyErr_GivenExceptionMatches' recursive behavior.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2291>
__________________________________


More information about the Python-bugs-list mailing list