[Python-Dev] PEP for allowing 'raise NewException from None'

Guido van Rossum guido at python.org
Fri Jan 27 20:54:31 CET 2012


On Fri, Jan 27, 2012 at 9:08 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Guido van Rossum wrote:
>>
>> Did you consider to just change the
>> words so users can ignore it more easily?
>
>
> Yes, that has also been discussed.
>
> Speaking for myself, it would be only slightly better.
>
> Speaking for everyone that wants context suppression (using Steven
> D'Aprano's words):  chained exceptions expose details to the caller that are
> irrelevant implementation details.
>
> It seems to me that generating the amount of information needed to track
> down errors is a balancing act between too much and too little; forcing the
> print of previous context when switching from exception A to exception B
> feels like too much:  at the very least it's extra noise; at the worst it
> can be confusing to the actual problem.  When the library (or custom class)
> author is catching A, saying "Yes, expected, now let's raise B instead", A
> is no longer necessary.
>
> Also, the programmer is free to *not* use 'from None', leaving the complete
> traceback in place.

Ok, got it. The developer has to explicitly say "raise <something>
from None" and that indicates they have really thought about the issue
of suppressing too much information and they are okay with it. I dig
that.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list