Message104832
To Evan Klitzke (eklitzke):
>I'm also interested in seeing this fixed. In the current behavior,
>the following code doesn't work:
>
><<< start code
>from functools import wraps
>
>def magic(func):
> @wraps(func)
> def even_more_magic(*args):
> return func(*args)
> return even_more_magic
>
>class Frob(object):
> @magic
> @classmethod
> def hello(cls):
> print '%r says hello' % (cls,)
>>>> end code
This code _should not_ work.
[Unbound] classmethod object is not a method or a function, it is even not a callable; it is a descriptor (returning callable). So, it cannot be wrapped or decorated in such way.
If you want something like this to work, you probably should place @classmethod on the upper level (in other words, apply classmethod after all other decorators):
@classmethod
@magic
def hello(cls):
print '%r says hello' % (cls,) |
|
Date |
User |
Action |
Args |
2010-05-03 12:43:41 | july | set | recipients:
+ july, ncoghlan, pitrou, benjamin.peterson, Antoine d'Otreppe, findepi, brian.curtin, eklitzke, yaubi, freakboy3742 |
2010-05-03 12:43:41 | july | set | messageid: <1272890621.44.0.644179526135.issue3445@psf.upfronthosting.co.za> |
2010-05-03 12:43:39 | july | link | issue3445 messages |
2010-05-03 12:43:39 | july | create | |
|