Message124824
>> 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. |
|
Date |
User |
Action |
Args |
2010-12-28 22:45:58 | ethan.furman | set | recipients:
+ ethan.furman, rhettinger, ncoghlan, pitrou, draghuram, mrabarnett, steven.daprano, poke |
2010-12-28 22:45:58 | ethan.furman | set | messageid: <1293576358.37.0.332952116724.issue6210@psf.upfronthosting.co.za> |
2010-12-28 22:45:54 | ethan.furman | link | issue6210 messages |
2010-12-28 22:45:54 | ethan.furman | create | |
|