[issue3445] Ignore missing attributes in functools.update_wrapper
Evan Klitzke e...@eklitzke.org added the comment: New patch included, with a test case. I had wanted to check the classmethod __module__ thing directly, but that proved to be elusive, since the classmethod gets the __module__ attribute if the module is '__main__', and you can't delete that attribute. My test just tries to assign another attribute which doesn't exist. I just tried to copy the style of the rest of the module, lmk if there are any problems. -- Added file: http://bugs.python.org/file15903/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
[issue3445] Ignore missing attributes in functools.update_wrapper
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