This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eklitzke
Recipients Antoine d'Otreppe, benjamin.peterson, eklitzke, findepi, ncoghlan, pitrou
Date 2010-01-14.00:50:39
SpamBayes Score 1.886824e-12
Marked as misclassified No
Message-id <1263430241.66.0.654422938652.issue3445@psf.upfronthosting.co.za>
In-reply-to
Content
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

It fails because classmethods don't have a __module__ attribute, as commented upon elsewhere in this issue. To fix this, you'd either have to either pass in an `assigned` parameter to the `wraps` function, or swap the order of decorator application (i.e. `classmethod(magic(hello))`).

This seems arbitrary and unnecessarily complex; skipping over a missing __module__ should be just fine. Mixing `functools.wraps` and `classmethod` is a relatively common use case that should be as simple as possible.

I've attached a trivial patch which just ignores missing "assigned" attributes.
History
Date User Action Args
2010-01-14 00:50:41eklitzkesetrecipients: + eklitzke, ncoghlan, pitrou, benjamin.peterson, Antoine d'Otreppe, findepi
2010-01-14 00:50:41eklitzkesetmessageid: <1263430241.66.0.654422938652.issue3445@psf.upfronthosting.co.za>
2010-01-14 00:50:40eklitzkelinkissue3445 messages
2010-01-14 00:50:39eklitzkecreate