Evan Klitzke <e...@eklitzke.org> added the comment:

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.

----------
keywords: +patch
nosy: +eklitzke
Added file: http://bugs.python.org/file15865/fix.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue3445>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to