Message97745
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. |
|
Date |
User |
Action |
Args |
2010-01-14 00:50:41 | eklitzke | set | recipients:
+ eklitzke, ncoghlan, pitrou, benjamin.peterson, Antoine d'Otreppe, findepi |
2010-01-14 00:50:41 | eklitzke | set | messageid: <1263430241.66.0.654422938652.issue3445@psf.upfronthosting.co.za> |
2010-01-14 00:50:40 | eklitzke | link | issue3445 messages |
2010-01-14 00:50:39 | eklitzke | create | |
|