Modify an exception before re-raising it
steve at pearwood.info
Fri Mar 6 09:47:25 CET 2009
Gabriel Genellina wrote:
> En Fri, 06 Mar 2009 04:29:16 -0200, Steven D'Aprano <steve at pearwood.info>
>> The behaviour I want is from raise_example2, but I'm not sure if this is
>> documented behaviour, or if it is something I can rely on. Is it
>> acceptable to modify an exception before re-raising it?
> I don't completely understand your question. Is it about the bare raise?
> It is documented here:
Yes, I read that before posting (waves to Steve Holden *wink*), so I
understood that raise on it's own re-raises the current exception.
> Or are you worried about modifying e.args? Hmm, it isn't explicitely
> forbidden, so I assume it's allowed... I've done it a few times -usually
> to provide more context to error messages- without bad consequences
That is precisely my concern. Sorry for not explaining myself better.
Okay, if other people are doing it, I'm happy to rely on it as something
which shouldn't just go away without warning. Thanks to everyone who
More information about the Python-list