mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Fixed #21513 -- Added method_decorator support for argumented decorator
Copied attributes into the decorated method and special case __name__ copy as this will not be present on a Class object. Added regression test to decorator suite.
This commit is contained in:
@@ -39,9 +39,13 @@ def method_decorator(decorator):
|
||||
update_wrapper(_wrapper, func)
|
||||
|
||||
return _wrapper
|
||||
update_wrapper(_dec, decorator)
|
||||
|
||||
update_wrapper(_dec, decorator, assigned=available_attrs(decorator))
|
||||
# Change the name to aid debugging.
|
||||
_dec.__name__ = 'method_decorator(%s)' % decorator.__name__
|
||||
if hasattr(decorator, '__name__'):
|
||||
_dec.__name__ = 'method_decorator(%s)' % decorator.__name__
|
||||
else:
|
||||
_dec.__name__ = 'method_decorator(%s)' % decorator.__class__.__name__
|
||||
return _dec
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user