summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-03-12 11:28:01 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-03-12 14:05:10 +0100
commit679af4058dae8a54438d95ceb943f449e78448c1 (patch)
tree570293a56851bde284f0580e2fdf678a6095d33b
parente1bafdbffa6e8b13db12c995eaa53508e047c83c (diff)
Restricted a workaround for a bug in Python to the affected versions.
-rw-r--r--django/utils/decorators.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/django/utils/decorators.py b/django/utils/decorators.py
index e653a736af..91444f0de6 100644
--- a/django/utils/decorators.py
+++ b/django/utils/decorators.py
@@ -2,12 +2,16 @@
from functools import wraps, update_wrapper, WRAPPER_ASSIGNMENTS
+from django.utils import six
+
+
class classonlymethod(classmethod):
def __get__(self, instance, owner):
if instance is not None:
raise AttributeError("This method is available only on the view class.")
return super(classonlymethod, self).__get__(instance, owner)
+
def method_decorator(decorator):
"""
Converts a function decorator into a method decorator
@@ -68,9 +72,13 @@ def decorator_from_middleware(middleware_class):
def available_attrs(fn):
"""
Return the list of functools-wrappable attributes on a callable.
- This is required as a workaround for http://bugs.python.org/issue3445.
+ This is required as a workaround for http://bugs.python.org/issue3445
+ under Python 2.
"""
- return tuple(a for a in WRAPPER_ASSIGNMENTS if hasattr(fn, a))
+ if six.PY3:
+ return WRAPPER_ASSIGNMENTS
+ else:
+ return tuple(a for a in WRAPPER_ASSIGNMENTS if hasattr(fn, a))
def make_middleware_decorator(middleware_class):