Code

Ticket #13827: django-func-kill.diff

File django-func-kill.diff, 7.3 KB (added by Alex, 4 years ago)
Line 
1diff --git a/django/conf/__init__.py b/django/conf/__init__.py
2index d94f6e9..ed1c2fd 100644
3--- a/django/conf/__init__.py
4+++ b/django/conf/__init__.py
5@@ -102,7 +102,7 @@ class Settings(object):
6                 new_installed_apps.append(app)
7         self.INSTALLED_APPS = new_installed_apps
8 
9-        if hasattr(time, 'tzset') and getattr(self, 'TIME_ZONE'):
10+        if hasattr(time, 'tzset') and self.TIME_ZONE:
11             # Move the time zone info into os.environ. See ticket #2315 for why
12             # we don't do this unconditionally (breaks Windows).
13             os.environ['TZ'] = self.TIME_ZONE
14diff --git a/django/contrib/admin/validation.py b/django/contrib/admin/validation.py
15index bee2891..8d7a8c9 100644
16--- a/django/contrib/admin/validation.py
17+++ b/django/contrib/admin/validation.py
18@@ -170,7 +170,7 @@ def validate_inline(cls, parent, parent_model):
19     fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True)
20 
21     # extra = 3
22-    if not isinstance(getattr(cls, 'extra'), int):
23+    if not isinstance(cls.extra, int):
24         raise ImproperlyConfigured("'%s.extra' should be a integer."
25                 % cls.__name__)
26 
27diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py
28index 169ae01..a184aea 100644
29--- a/django/contrib/auth/__init__.py
30+++ b/django/contrib/auth/__init__.py
31@@ -20,15 +20,12 @@ def load_backend(path):
32         cls = getattr(mod, attr)
33     except AttributeError:
34         raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
35-    try:
36-        getattr(cls, 'supports_object_permissions')
37-    except AttributeError:
38+    if not hasattr(cls, "supports_object_permissions"):
39         warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
40              PendingDeprecationWarning)
41         cls.supports_object_permissions = False
42-    try:
43-        getattr(cls, 'supports_anonymous_user')
44-    except AttributeError:
45+
46+    if not hasattr(cls, 'supports_anonymous_user'):
47         warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
48              PendingDeprecationWarning)
49         cls.supports_anonymous_user = False
50diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py
51index f3c1da2..152edc9 100644
52--- a/django/contrib/gis/sitemaps/views.py
53+++ b/django/contrib/gis/sitemaps/views.py
54@@ -93,7 +93,7 @@ def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB
55         else:
56             qs = klass._default_manager.using(using).all()
57         for mod in qs:
58-            setattr(mod, 'kml', getattr(mod, field_name).kml)
59+            mod.kml = getattr(mod, field_name).kml)
60             placemarks.append(mod)
61 
62     # Getting the render function and rendering to the correct.
63diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py
64index 1b60290..c3bb0e1 100644
65--- a/django/core/cache/__init__.py
66+++ b/django/core/cache/__init__.py
67@@ -63,7 +63,7 @@ def get_cache(backend_uri):
68     else:
69         name = scheme
70     module = importlib.import_module(name)
71-    return getattr(module, 'CacheClass')(host, params)
72+    return module.CacheClass(host, params)
73 
74 cache = get_cache(settings.CACHE_BACKEND)
75 
76diff --git a/django/db/models/base.py b/django/db/models/base.py
77index 6304e00..43ecbcc 100644
78--- a/django/db/models/base.py
79+++ b/django/db/models/base.py
80@@ -509,7 +509,7 @@ class Model(object):
81                     # autopopulate the _order field
82                     field = meta.order_with_respect_to
83                     order_value = manager.using(using).filter(**{field.name: getattr(self, field.attname)}).count()
84-                    setattr(self, '_order', order_value)
85+                    self._order = order_value
86 
87                 if not pk_set:
88                     if force_update:
89diff --git a/django/db/models/options.py b/django/db/models/options.py
90index 5d84ab6..5cf911d 100644
91--- a/django/db/models/options.py
92+++ b/django/db/models/options.py
93@@ -79,14 +79,14 @@ class Options(object):
94             # unique_together can be either a tuple of tuples, or a single
95             # tuple of two strings. Normalize it to a tuple of tuples, so that
96             # calling code can uniformly expect that.
97-            ut = meta_attrs.pop('unique_together', getattr(self, 'unique_together'))
98+            ut = meta_attrs.pop('unique_together', self.unique_together)
99             if ut and not isinstance(ut[0], (tuple, list)):
100                 ut = (ut,)
101-            setattr(self, 'unique_together', ut)
102+            self.unique_together = ut
103 
104             # verbose_name_plural is a special case because it uses a 's'
105             # by default.
106-            setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', string_concat(self.verbose_name, 's')))
107+            self.verbose_name_plural = meta_attrs.pop('verbose_name_plural', string_concat(self.verbose_name, 's'))
108 
109             # Any leftover attributes must be invalid.
110             if meta_attrs != {}:
111diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
112index f75b155..c7b79fe 100644
113--- a/django/db/models/query_utils.py
114+++ b/django/db/models/query_utils.py
115@@ -256,9 +256,8 @@ def deferred_class_factory(model, attrs):
116     deferred attributes to a particular instance of the model.
117     """
118     class Meta:
119-        pass
120-    setattr(Meta, "proxy", True)
121-    setattr(Meta, "app_label", model._meta.app_label)
122+        proxy = True
123+        app_label = model._meta.app_label
124 
125     # The app_cache wants a unique name for each model, otherwise the new class
126     # won't be created (we get an old one back). Therefore, we generate the
127diff --git a/django/forms/forms.py b/django/forms/forms.py
128index b3718ef..343956b 100644
129--- a/django/forms/forms.py
130+++ b/django/forms/forms.py
131@@ -268,7 +268,7 @@ class BaseForm(StrAndUnicode):
132         self._clean_form()
133         self._post_clean()
134         if self._errors:
135-            delattr(self, 'cleaned_data')
136+            del self.cleaned_data
137 
138     def _clean_fields(self):
139         for name, field in self.fields.items():
140diff --git a/django/test/simple.py b/django/test/simple.py
141index 9013042..be5550f 100644
142--- a/django/test/simple.py
143+++ b/django/test/simple.py
144@@ -58,7 +58,7 @@ class DjangoTestRunner(unittest.TextTestRunner):
145                 func(test)
146             return stoptest
147 
148-        setattr(result, 'stopTest', stoptest_override(result.stopTest))
149+        result.stopTest = stoptest_override(result.stopTest)
150         return result
151 
152 def get_tests(app_module):
153diff --git a/tests/regressiontests/comment_tests/tests/app_api_tests.py b/tests/regressiontests/comment_tests/tests/app_api_tests.py
154index c4d9ebf..4015487 100644
155--- a/tests/regressiontests/comment_tests/tests/app_api_tests.py
156+++ b/tests/regressiontests/comment_tests/tests/app_api_tests.py
157@@ -41,7 +41,7 @@ class CustomCommentTest(CommentTestCase):
158         del settings.INSTALLED_APPS[-1]
159         settings.COMMENTS_APP = self.old_comments_app
160         if settings.COMMENTS_APP is None:
161-            delattr(settings._wrapped, 'COMMENTS_APP')
162+            del settings._wrapped.COMMENTS_APP
163 
164     def testGetCommentApp(self):
165         from regressiontests.comment_tests import custom_comments