Author july
Recipients Antoine d'Otreppe, benjamin.peterson, brian.curtin, eklitzke, findepi, freakboy3742, july, ncoghlan, pitrou, yaubi
Date 2010-05-03.12:43:39
SpamBayes Score 9.23427e-06
Marked as misclassified No
Message-id <1272890621.44.0.644179526135.issue3445@psf.upfronthosting.co.za>
In-reply-to
Content
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,)
History
Date User Action Args
2010-05-03 12:43:41julysetrecipients: + july, ncoghlan, pitrou, benjamin.peterson, Antoine d'Otreppe, findepi, brian.curtin, eklitzke, yaubi, freakboy3742
2010-05-03 12:43:41julysetmessageid: <1272890621.44.0.644179526135.issue3445@psf.upfronthosting.co.za>
2010-05-03 12:43:39julylinkissue3445 messages
2010-05-03 12:43:39julycreate