From 80cd64ee17191ffb235c5850a8fa60cae96c1b89 Mon Sep 17 00:00:00 2001 From: Marc Tamlyn Date: Sun, 9 Feb 2014 11:10:05 +0000 Subject: Fixed #21247 -- Made method_decorator play nicely with descriptors When a method decorator was used in conjunction with a decorator implemented as a descriptor, method_decorator did not correctly respect the method binding. Thanks for Graham Dumpleton for the report and initial patch. --- django/utils/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django') diff --git a/django/utils/decorators.py b/django/utils/decorators.py index 4ccf1d69df..fbcf4edf13 100644 --- a/django/utils/decorators.py +++ b/django/utils/decorators.py @@ -22,7 +22,7 @@ def method_decorator(decorator): def _wrapper(self, *args, **kwargs): @decorator def bound_func(*args2, **kwargs2): - return func(self, *args2, **kwargs2) + return func.__get__(self, type(self))(*args2, **kwargs2) # bound_func has the signature that 'decorator' expects i.e. no # 'self' argument, but it is a closure over self so it can call # 'func' correctly. -- cgit v1.3