classification
Title: Patch for catching exceptions that do not inherit from BaseException
Type: Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: belopolsky, brett.cannon, gvanrossum, taicki
Priority: normal Keywords: patch

Created on 2008-03-17 20:35 by taicki, last changed 2008-03-18 03:51 by belopolsky. This issue is now closed.

Files
File name Uploaded Description Edit
catchexc.patch taicki, 2008-03-17 20:35
Messages (8)
msg63761 - (view) Author: Taek Joo Kim (taicki) * Date: 2008-03-17 20:35
With this patch it prints warning message for catching exceptions that
don't inherit from BaseException when -3 flag is used.
msg63771 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-03-17 20:58
This belongs to issue2291.
msg63843 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-03-18 01:52
I'll review this once I address issue2291.
msg63855 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-03-18 02:50
Thanks!

Applied as r61475.
msg63857 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-03-18 02:57
I left the following comment in issue2291 pertaining to this patch:

"""
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.
"""
msg63863 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-03-18 03:09
Alex, can you please open a separate bug for that? The cross-posting of
comments is unhelpful, and the issue was not introduced by this patch.
msg63867 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-03-18 03:16
I've checked a temporary work-around for that issue and another one in
r61478.  This now has some false negatives; that's better than false
positives IMO.
msg63876 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-03-18 03:51
On Mon, Mar 17, 2008 at 11:09 PM, Guido van Rossum
<report@bugs.python.org> wrote:
>
>  Alex, can you please open a separate bug for that? The cross-posting of
>  comments is unhelpful, and the issue was not introduced by this patch.

Please see issue2380.
History
Date User Action Args
2008-03-18 03:51:41belopolskysetmessages: + msg63876
2008-03-18 03:16:11gvanrossumsetmessages: + msg63867
2008-03-18 03:09:23gvanrossumsetmessages: + msg63863
2008-03-18 02:57:13belopolskysetmessages: + msg63857
2008-03-18 02:50:10gvanrossumsetstatus: open -> closed
resolution: accepted
messages: + msg63855
2008-03-18 01:52:10gvanrossumsetpriority: normal
assignee: gvanrossum
messages: + msg63843
nosy: + gvanrossum
2008-03-17 20:58:38belopolskysetnosy: + brett.cannon, belopolsky
messages: + msg63771
2008-03-17 20:35:48taickicreate