Function name unchanged in error message
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Feb 1 16:25:41 EST 2010
En Sat, 30 Jan 2010 06:28:19 -0300, Peter Otten <__peter__ at web.de>
escribió:
> Gabriel Genellina wrote:
>> En Fri, 29 Jan 2010 13:09:40 -0300, Michele Simionato
>> <michele.simionato at gmail.com> escribió:
>>> On Jan 29, 2:30 pm, andrew cooke <and... at acooke.org> wrote:
>>>> Is there any way to change the name of the function in an error
>>>> message? In the example below I'd like the error to refer to bar(),
>>>> for example (the motivation is related function decorators - I'd like
>>>> the wrapper function to give the same name)
>>>
>>> Use the decorator module which does the right thing:
>>> http://pypi.python.org/pypi/decorator
>>
>> The decorator module is a very fine addition to anyone's tool set -- but
>> in this case it is enough to use the wraps() function from the functools
>> standard module.
>
> I don't know about the decorator module, but functools.wraps() doesn't
> affect the error message:
It seems I misunderstood the original request and got it backwards - but
then I have to question the usefulness of doing so. If an error happens in
the "decorating" function (as opposed to inside the function being
decorated) I'd like the error to be reported as such, in the "decorating"
function (else tracebacks and line numbers would be lying).
--
Gabriel Genellina
More information about the Python-list
mailing list