Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Restricted a workaround for a bug in Python to the affected versions.

  • Loading branch information...
commit 679af4058dae8a54438d95ceb943f449e78448c1 1 parent e1bafdb
Aymeric Augustin authored

Showing 1 changed file with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. 12  django/utils/decorators.py
12  django/utils/decorators.py
@@ -2,12 +2,16 @@
2 2
 
3 3
 from functools import wraps, update_wrapper, WRAPPER_ASSIGNMENTS
4 4
 
  5
+from django.utils import six
  6
+
  7
+
5 8
 class classonlymethod(classmethod):
6 9
     def __get__(self, instance, owner):
7 10
         if instance is not None:
8 11
             raise AttributeError("This method is available only on the view class.")
9 12
         return super(classonlymethod, self).__get__(instance, owner)
10 13
 
  14
+
11 15
 def method_decorator(decorator):
12 16
     """
13 17
     Converts a function decorator into a method decorator
@@ -68,9 +72,13 @@ def decorator_from_middleware(middleware_class):
68 72
 def available_attrs(fn):
69 73
     """
70 74
     Return the list of functools-wrappable attributes on a callable.
71  
-    This is required as a workaround for http://bugs.python.org/issue3445.
  75
+    This is required as a workaround for http://bugs.python.org/issue3445
  76
+    under Python 2.
72 77
     """
73  
-    return tuple(a for a in WRAPPER_ASSIGNMENTS if hasattr(fn, a))
  78
+    if six.PY3:
  79
+        return WRAPPER_ASSIGNMENTS
  80
+    else:
  81
+        return tuple(a for a in WRAPPER_ASSIGNMENTS if hasattr(fn, a))
74 82
 
75 83
 
76 84
 def make_middleware_decorator(middleware_class):

0 notes on commit 679af40

Please sign in to comment.
Something went wrong with that request. Please try again.