Re: [Python-ideas] suppressing exception context when it is not relevant

2016-10-10 Thread Nick Coghlan
On 11 October 2016 at 10:43, Václav Dvořák wrote: > But I find this misleading, as the original KeyError is not really an error > at all. I could of course avoid the situation by changing the try/except > (EAFP) into a test for the key's presence (LBYL) but that's not very > Pythonic and less thre

Re: [Python-ideas] suppressing exception context when it is not relevant

2016-10-10 Thread MRAB
On 2016-10-11 01:43, Václav Dvořák wrote: I'm aware of "raise ... from None" (from PEP 415). However, how can I achieve that same effect (of suppressing the "During handling of the above exception, another exception occurred" message) without having control over the code that is executed from the

[Python-ideas] suppressing exception context when it is not relevant

2016-10-10 Thread Václav Dvořák
I'm aware of "raise ... from None" (from PEP 415). However, how can I achieve that same effect (of suppressing the "During handling of the above exception, another exception occurred" message) without having control over the code that is executed from the except clause? I thought that sys.exc_clear