Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Merge pull request: all DeprecationWarnings now stacklevel 2. Closes #18127, #18780 #349

Closed
wants to merge 3 commits into from

2 participants

Nick Martini Aymeric Augustin
Nick Martini

all DeprecationWarning now stacklevel 2. tickets #18127, #18780

Aymeric Augustin
Owner

I'm going to close this pull request because it's stale.

Unfortunately, such patches are easier to redo than to review. I appreciate your effort but I'm unable to take advantage of it. Sorry!

Aymeric Augustin aaugustin closed this December 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
4  django/conf/__init__.py
@@ -73,7 +73,7 @@ def __setattr__(self, name, value):
73 73
             raise ImproperlyConfigured("If set, %s must end with a slash" % name)
74 74
         elif name == "ADMIN_MEDIA_PREFIX":
75 75
             warnings.warn("The ADMIN_MEDIA_PREFIX setting has been removed; "
76  
-                          "use STATIC_URL instead.", DeprecationWarning)
  76
+                          "use STATIC_URL instead.", DeprecationWarning, stacklevel=2)
77 77
         elif name == "ALLOWED_INCLUDE_ROOTS" and isinstance(value, six.string_types):
78 78
             raise ValueError("The ALLOWED_INCLUDE_ROOTS setting must be set "
79 79
                 "to a tuple, not a string.")
@@ -193,7 +193,7 @@ def compat_patch_logging_config(logging_config):
193 193
             "handler: adding implicit debug-false-only filter. "
194 194
             "See http://docs.djangoproject.com/en/dev/releases/1.4/"
195 195
             "#request-exceptions-are-now-always-logged",
196  
-            DeprecationWarning)
  196
+            DeprecationWarning, stacklevel=2)
197 197
 
198 198
         filter_name = "require_debug_false"
199 199
 
2  django/conf/urls/defaults.py
... ...
@@ -1,6 +1,6 @@
1 1
 import warnings
2 2
 warnings.warn("django.conf.urls.defaults is deprecated; use django.conf.urls instead",
3  
-              DeprecationWarning)
  3
+              DeprecationWarning, stacklevel=2)
4 4
 
5 5
 from django.conf.urls import (handler403, handler404, handler500,
6 6
         include, patterns, url)
2  django/contrib/admin/templatetags/adminmedia.py
@@ -11,5 +11,5 @@ def admin_media_prefix():
11 11
     """
12 12
     warnings.warn(
13 13
         "The admin_media_prefix template tag is deprecated. "
14  
-        "Use the static template tag instead.", DeprecationWarning)
  14
+        "Use the static template tag instead.", DeprecationWarning, stacklevel=2)
15 15
     return PrefixNode.handle_simple("ADMIN_MEDIA_PREFIX")
2  django/contrib/databrowse/__init__.py
@@ -2,4 +2,4 @@
2 2
 from django.contrib.databrowse.sites import DatabrowsePlugin, ModelDatabrowse, DatabrowseSite, site
3 3
 
4 4
 
5  
-warnings.warn("The Databrowse contrib app is deprecated", DeprecationWarning)
  5
+warnings.warn("The Databrowse contrib app is deprecated", DeprecationWarning, stacklevel=2)
2  django/contrib/formtools/wizard/legacy.py
@@ -39,7 +39,7 @@ def __init__(self, form_list, initial=None):
39 39
         warnings.warn(
40 40
             'Old-style form wizards have been deprecated; use the class-based '
41 41
             'views in django.contrib.formtools.wizard.views instead.',
42  
-            DeprecationWarning)
  42
+            DeprecationWarning, stacklevel=2)
43 43
 
44 44
     def __repr__(self):
45 45
         return "step: %d\nform_list: %s\ninitial_data: %s" % (self.step, self.form_list, self.initial)
2  django/contrib/localflavor/uk/forms.py
@@ -3,7 +3,7 @@
3 3
 import warnings
4 4
 warnings.warn(
5 5
     'The "UK" prefix for United Kingdom has been deprecated in favour of the '
6  
-    'GB code. Please use the new GB-prefixed names.', DeprecationWarning)
  6
+    'GB code. Please use the new GB-prefixed names.', DeprecationWarning, stacklevel=2)
7 7
 
8 8
 UKPostcodeField = forms.GBPostcodeField
9 9
 UKCountySelect = forms.GBCountySelect
2  django/contrib/localflavor/uk/uk_regions.py
@@ -6,7 +6,7 @@
6 6
 import warnings
7 7
 warnings.warn(
8 8
     'The "UK" prefix for United Kingdom has been deprecated in favour of the '
9  
-    'GB code. Please use the new GB-prefixed names.', DeprecationWarning)
  9
+    'GB code. Please use the new GB-prefixed names.', DeprecationWarning, stacklevel=2)
10 10
 
11 11
 UK_NATIONS_CHOICES = GB_NATIONS_CHOICES
12 12
 UK_REGION_CHOICES  = GB_REGION_CHOICES
4  django/core/management/__init__.py
@@ -401,7 +401,7 @@ def setup_environ(settings_mod, original_settings_path=None):
401 401
         "you likely need to update your 'manage.py'; "
402 402
         "please see the Django 1.4 release notes "
403 403
         "(https://docs.djangoproject.com/en/dev/releases/1.4/).",
404  
-        DeprecationWarning)
  404
+        DeprecationWarning, stacklevel=2)
405 405
 
406 406
     # Add this project to sys.path so that it's importable in the conventional
407 407
     # way. For example, if this file (manage.py) lives in a directory
@@ -457,7 +457,7 @@ def execute_manager(settings_mod, argv=None):
457 457
         "you likely need to update your 'manage.py'; "
458 458
         "please see the Django 1.4 release notes "
459 459
         "(https://docs.djangoproject.com/en/dev/releases/1.4/).",
460  
-        DeprecationWarning)
  460
+        DeprecationWarning, stacklevel=2)
461 461
 
462 462
     setup_environ(settings_mod)
463 463
     utility = ManagementUtility(argv)
4  django/middleware/common.py
@@ -130,14 +130,14 @@ def _is_ignorable_404(uri):
130 130
     if getattr(settings, 'IGNORABLE_404_STARTS', ()):
131 131
         import warnings
132 132
         warnings.warn('The IGNORABLE_404_STARTS setting has been deprecated '
133  
-                      'in favor of IGNORABLE_404_URLS.', DeprecationWarning)
  133
+                      'in favor of IGNORABLE_404_URLS.', DeprecationWarning, stacklevel=2)
134 134
         for start in settings.IGNORABLE_404_STARTS:
135 135
             if uri.startswith(start):
136 136
                 return True
137 137
     if getattr(settings, 'IGNORABLE_404_ENDS', ()):
138 138
         import warnings
139 139
         warnings.warn('The IGNORABLE_404_ENDS setting has been deprecated '
140  
-                      'in favor of IGNORABLE_404_URLS.', DeprecationWarning)
  140
+                      'in favor of IGNORABLE_404_URLS.', DeprecationWarning, stacklevel=2)
141 141
         for end in settings.IGNORABLE_404_ENDS:
142 142
             if uri.endswith(end):
143 143
                 return True
2  django/template/defaultfilters.py
@@ -55,7 +55,7 @@ def _dec(*args, **kwargs):
55 55
             warnings.warn("Setting the %s attribute of a template filter "
56 56
                           "function is deprecated; use @register.filter(%s=%s) "
57 57
                           "instead" % (attr, attr, getattr(func, attr)),
58  
-                          DeprecationWarning)
  58
+                          DeprecationWarning, stacklevel=2)
59 59
             setattr(_dec, attr, getattr(func, attr))
60 60
 
61 61
     return wraps(func)(_dec)
2  django/utils/copycompat.py
@@ -7,7 +7,7 @@
7 7
 import warnings
8 8
 
9 9
 warnings.warn("django.utils.copycompat is deprecated; use the native copy module instead",
10  
-              DeprecationWarning)
  10
+              DeprecationWarning, stacklevel=2)
11 11
 
12 12
 # Monkeypatch copy's deepcopy registry to handle functions correctly.
13 13
 if (hasattr(copy, '_deepcopy_dispatch') and types.FunctionType not in copy._deepcopy_dispatch):
2  django/utils/hashcompat.py
@@ -6,7 +6,7 @@
6 6
 
7 7
 import warnings
8 8
 warnings.warn("django.utils.hashcompat is deprecated; use hashlib instead",
9  
-              DeprecationWarning)
  9
+              DeprecationWarning, stacklevel=2)
10 10
 
11 11
 import hashlib
12 12
 md5_constructor = hashlib.md5
4  django/utils/itercompat.py
@@ -24,10 +24,10 @@ def product(*args, **kwds):
24 24
 
25 25
 def all(iterable):
26 26
     warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead",
27  
-                  DeprecationWarning)
  27
+                  DeprecationWarning, stacklevel=2)
28 28
     return builtins.all(iterable)
29 29
 
30 30
 def any(iterable):
31 31
     warnings.warn("django.utils.itercompat.any is deprecated; use the native version instead",
32  
-                  DeprecationWarning)
  32
+                  DeprecationWarning, stacklevel=2)
33 33
     return builtins.any(iterable)
4  django/utils/text.py
@@ -211,14 +211,14 @@ def _html_words(self, length, truncate):
211 211
 
212 212
 def truncate_words(s, num, end_text='...'):
213 213
     warnings.warn('This function has been deprecated. Use the Truncator class '
214  
-        'in django.utils.text instead.', category=DeprecationWarning)
  214
+        'in django.utils.text instead.', category=DeprecationWarning, stacklevel=2)
215 215
     truncate = end_text and ' %s' % end_text or ''
216 216
     return Truncator(s).words(num, truncate=truncate)
217 217
 truncate_words = allow_lazy(truncate_words, six.text_type)
218 218
 
219 219
 def truncate_html_words(s, num, end_text='...'):
220 220
     warnings.warn('This function has been deprecated. Use the Truncator class '
221  
-        'in django.utils.text instead.', category=DeprecationWarning)
  221
+        'in django.utils.text instead.', category=DeprecationWarning, stacklevel=2)
222 222
     truncate = end_text and ' %s' % end_text or ''
223 223
     return Truncator(s).words(num, truncate=truncate, html=True)
224 224
 truncate_html_words = allow_lazy(truncate_html_words, six.text_type)
4  django/utils/unittest/case.py
@@ -339,7 +339,7 @@ def run(self, result=None):
339 339
                         addExpectedFailure(self, e.exc_info)
340 340
                     else:
341 341
                         warnings.warn("Use of a TestResult without an addExpectedFailure method is deprecated",
342  
-                                      DeprecationWarning)
  342
+                                      DeprecationWarning, stacklevel=2)
343 343
                         result.addSuccess(self)
344 344
                 except _UnexpectedSuccess:
345 345
                     addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
@@ -347,7 +347,7 @@ def run(self, result=None):
347 347
                         addUnexpectedSuccess(self)
348 348
                     else:
349 349
                         warnings.warn("Use of a TestResult without an addUnexpectedSuccess method is deprecated",
350  
-                                      DeprecationWarning)
  350
+                                      DeprecationWarning, stacklevel=2)
351 351
                         result.addFailure(self, sys.exc_info())
352 352
                 except SkipTest, e:
353 353
                     self._addSkip(result, str(e))
4  django/views/decorators/csrf.py
@@ -55,7 +55,7 @@ def csrf_response_exempt(view_func):
55 55
     """
56 56
     warnings.warn("csrf_response_exempt is deprecated. It no longer performs a "
57 57
                   "function, and calls to it can be removed.",
58  
-                  DeprecationWarning)
  58
+                  DeprecationWarning, stacklevel=2)
59 59
     return view_func
60 60
 
61 61
 def csrf_view_exempt(view_func):
@@ -63,7 +63,7 @@ def csrf_view_exempt(view_func):
63 63
     Marks a view function as being exempt from CSRF view protection.
64 64
     """
65 65
     warnings.warn("csrf_view_exempt is deprecated. Use csrf_exempt instead.",
66  
-                  DeprecationWarning)
  66
+                  DeprecationWarning, stacklevel=2)
67 67
     return csrf_exempt(view_func)
68 68
 
69 69
 def csrf_exempt(view_func):
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.