Re: Modify an exception before re-raising it

2009-03-06 Thread Terry Reedy
Steven D'Aprano wrote: Okay, if other people are doing it, I'm happy to rely on it as something which shouldn't just go away without warning. At least, it will not go away without fuss. I would guess that modifying the message is an intended use of bare 'raise', but that is not documented.

Re: Modify an exception before re-raising it

2009-03-06 Thread Ben Finney
Steven D'Aprano writes: > 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 replied. If you only want to modify the exception's message string, the ‘message’ attribute is standard IIRC. No need to re-

Re: Modify an exception before re-raising it

2009-03-06 Thread Steven D'Aprano
Gabriel Genellina wrote: > En Fri, 06 Mar 2009 04:29:16 -0200, Steven D'Aprano > escribió: ... >> 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?

Re: Modify an exception before re-raising it

2009-03-05 Thread Steve Holden
Steven D'Aprano wrote: > I wish to catch an exception, modify the error message, and re-raise it. > There are two ways I know of to do this, with subtly different effects: > def raise_example1(): > ... try: > ... None() > ... except TypeError, e: > ... e.args =

Re: Modify an exception before re-raising it

2009-03-05 Thread Gabriel Genellina
En Fri, 06 Mar 2009 04:29:16 -0200, Steven D'Aprano escribió: I wish to catch an exception, modify the error message, and re-raise it. There are two ways I know of to do this, with subtly different effects: def raise_example1(): ... try: ... None() ... except TypeError,

Re: Modify an exception before re-raising it

2009-03-05 Thread Chris Rebert
On Thu, Mar 5, 2009 at 10:29 PM, Steven D'Aprano wrote: > I wish to catch an exception, modify the error message, and re-raise it. > There are two ways I know of to do this, with subtly different effects: > def raise_example1(): > ...     try: > ...             None() > ...     except TypeErr