This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients draghuram, ethan.furman, mrabarnett, ncoghlan, pitrou, poke, rhettinger, steven.daprano
Date 2010-12-28.22:45:54
SpamBayes Score 0.00012915797
Marked as misclassified No
Message-id <1293576358.37.0.332952116724.issue6210@psf.upfronthosting.co.za>
In-reply-to
Content
>> During handling of the above exception, another exception occurred:
>> 
>> This is a blatant falsehood -- another exception did not occur, a
>> different exception was raised.
> 
> This doesn't make any difference in any other context, so why would it
> here?

I'm not sure I understand what you are saying -- could you rephrase?


> By the way, this is all described in detail in a PEP:
> http://www.python.org/dev/peps/pep-3134/

Yes, I know -- and from the PEP:

Rationale

    The Python-Dev discussions revealed interest in exception chaining
    for two quite different purposes.  To handle the unexpected raising
    of a secondary exception, the exception must be retained implicitly.
    To support intentional translation of an exception, there must be a
    way to chain exceptions explicitly.  This PEP addresses both.

Open Issue: Suppressing Context

    As written, this PEP makes it impossible to suppress '__context__',
    since setting exc.__context__ to None in an 'except' or 'finally'
    clause will only result in it being set again when exc is raised.

The two motivations are excellent, and I have no issue with them; what I have issue with is that it is no longer possible to discard previous context.  If I want to change the error message, I can use

        except ValueError as exc:
            raise AttributeError("blah") from exc

and then get

  The above exception was the direct cause of the following exception

I would also like to see:

        except ValueError as exc:
            raise AttributeError("blah") with exc

to get 

  During handling of the above exception, another exception occurred

which would be the same as:

        1/0

to get

  During handling of the above exception, another exception occurred

and, finally, if all I have is 

        except ValueError as exc:
            raise AttributeError("blah")

I just get the normal, previous context free, traceback.
History
Date User Action Args
2010-12-28 22:45:58ethan.furmansetrecipients: + ethan.furman, rhettinger, ncoghlan, pitrou, draghuram, mrabarnett, steven.daprano, poke
2010-12-28 22:45:58ethan.furmansetmessageid: <1293576358.37.0.332952116724.issue6210@psf.upfronthosting.co.za>
2010-12-28 22:45:54ethan.furmanlinkissue6210 messages
2010-12-28 22:45:54ethan.furmancreate