Turning a signature-changing decorator into a signature-preserving one

Gustavo Narea me at gustavonarea.net
Sat Feb 14 07:30:08 EST 2009


On Feb 14, 6:38 am, Michele Simionato <michele.simion... at gmail.com>
wrote:
> On Feb 14, 12:56 am, Gustavo Narea <m... at gustavonarea.net> wrote:
>
>
>
> > Hello, everybody.
>
> > I have this signature-changing decorator
> > <http://paste.chrisarndt.de/paste/15aac02a90094a41a13a1b9b85a14dd6>
> > which I
> > want to turn into a signature-preserving one. Here's my try
> > <http://paste.chrisarndt.de/paste/d0f835c00f824437bf4a0898f8020fc8>,
> > but I get
> > this error:http://paste.chrisarndt.de/paste/33e06be6e6d74e49b05c45534dfcc9fe?wra...
>
> > What am I doing wrong? I think it looks like this example:http://pypi.python.org/pypi/decorator#async
>
> > Thanks in advance.
>
> >   - Gustavo.
>
> > PS: functols.wrap is not an option because my code has to work with
> > Python 2.4+.
>
> Difficult to see what is happening, since you have so many
> dependencies. However, from the traceback I would say that
> you are passing to the decorator a function with a __name__
> attribute which is None. I would insert a call to pdb here
>
> def __call__(self, func):
>         import pdb; pdb.set_trace()
>         return decorator(self.call, func)
>
> and I would inspect func.__name__.
>
> HTH,
>
>                                  M.Simionato

Thanks for your response, Michele.

This is what I get:
"""
(Pdb) func.__name__
'greetings'
(Pdb) func.__dict__
{}
(Pdb) func.__module__
'pylonsproject.controllers.root'
"""

Which seems correct to me.

By the way, I forgot to mention that what is decorated is an instance
method. I don't know if that would change something.

Thanks in advance.

  - Gustavo.



More information about the Python-list mailing list