July Tikhonov <[email protected]> added the comment:
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,)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue3445>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com