Skip to content

Commit

Permalink
setting stacklevel to 2 for all DeprecationWarning, tickets #18780, #…
Browse files Browse the repository at this point in the history
…18127
  • Loading branch information
nmartini committed Sep 7, 2012
1 parent fe2f856 commit b9d12f1
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions django/conf/__init__.py
Expand Up @@ -73,7 +73,7 @@ def __setattr__(self, name, value):
raise ImproperlyConfigured("If set, %s must end with a slash" % name)
elif name == "ADMIN_MEDIA_PREFIX":
warnings.warn("The ADMIN_MEDIA_PREFIX setting has been removed; "
"use STATIC_URL instead.", DeprecationWarning)
"use STATIC_URL instead.", DeprecationWarning, stacklevel=2)
elif name == "ALLOWED_INCLUDE_ROOTS" and isinstance(value, six.string_types):
raise ValueError("The ALLOWED_INCLUDE_ROOTS setting must be set "
"to a tuple, not a string.")
Expand Down Expand Up @@ -193,7 +193,7 @@ def compat_patch_logging_config(logging_config):
"handler: adding implicit debug-false-only filter. "
"See http://docs.djangoproject.com/en/dev/releases/1.4/"
"#request-exceptions-are-now-always-logged",
DeprecationWarning)
DeprecationWarning, stacklevel=2)

filter_name = "require_debug_false"

Expand Down
2 changes: 1 addition & 1 deletion django/conf/urls/defaults.py
@@ -1,6 +1,6 @@
import warnings
warnings.warn("django.conf.urls.defaults is deprecated; use django.conf.urls instead",
DeprecationWarning)
DeprecationWarning, stacklevel=2)

from django.conf.urls import (handler403, handler404, handler500,
include, patterns, url)
2 changes: 1 addition & 1 deletion django/contrib/admin/templatetags/adminmedia.py
Expand Up @@ -11,5 +11,5 @@ def admin_media_prefix():
"""
warnings.warn(
"The admin_media_prefix template tag is deprecated. "
"Use the static template tag instead.", DeprecationWarning)
"Use the static template tag instead.", DeprecationWarning, stacklevel=2)
return PrefixNode.handle_simple("ADMIN_MEDIA_PREFIX")
2 changes: 1 addition & 1 deletion django/contrib/databrowse/__init__.py
Expand Up @@ -2,4 +2,4 @@
from django.contrib.databrowse.sites import DatabrowsePlugin, ModelDatabrowse, DatabrowseSite, site


warnings.warn("The Databrowse contrib app is deprecated", DeprecationWarning)
warnings.warn("The Databrowse contrib app is deprecated", DeprecationWarning, stacklevel=2)
2 changes: 1 addition & 1 deletion django/contrib/formtools/wizard/legacy.py
Expand Up @@ -39,7 +39,7 @@ def __init__(self, form_list, initial=None):
warnings.warn(
'Old-style form wizards have been deprecated; use the class-based '
'views in django.contrib.formtools.wizard.views instead.',
DeprecationWarning)
DeprecationWarning, stacklevel=2)

def __repr__(self):
return "step: %d\nform_list: %s\ninitial_data: %s" % (self.step, self.form_list, self.initial)
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/localflavor/uk/forms.py
Expand Up @@ -3,7 +3,7 @@
import warnings
warnings.warn(
'The "UK" prefix for United Kingdom has been deprecated in favour of the '
'GB code. Please use the new GB-prefixed names.', DeprecationWarning)
'GB code. Please use the new GB-prefixed names.', DeprecationWarning, stacklevel=2)

UKPostcodeField = forms.GBPostcodeField
UKCountySelect = forms.GBCountySelect
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/localflavor/uk/uk_regions.py
Expand Up @@ -6,7 +6,7 @@
import warnings
warnings.warn(
'The "UK" prefix for United Kingdom has been deprecated in favour of the '
'GB code. Please use the new GB-prefixed names.', DeprecationWarning)
'GB code. Please use the new GB-prefixed names.', DeprecationWarning, stacklevel=2)

UK_NATIONS_CHOICES = GB_NATIONS_CHOICES
UK_REGION_CHOICES = GB_REGION_CHOICES
4 changes: 2 additions & 2 deletions django/core/management/__init__.py
Expand Up @@ -401,7 +401,7 @@ def setup_environ(settings_mod, original_settings_path=None):
"you likely need to update your 'manage.py'; "
"please see the Django 1.4 release notes "
"(https://docs.djangoproject.com/en/dev/releases/1.4/).",
DeprecationWarning)
DeprecationWarning, stacklevel=2)

# Add this project to sys.path so that it's importable in the conventional
# way. For example, if this file (manage.py) lives in a directory
Expand Down Expand Up @@ -457,7 +457,7 @@ def execute_manager(settings_mod, argv=None):
"you likely need to update your 'manage.py'; "
"please see the Django 1.4 release notes "
"(https://docs.djangoproject.com/en/dev/releases/1.4/).",
DeprecationWarning)
DeprecationWarning, stacklevel=2)

setup_environ(settings_mod)
utility = ManagementUtility(argv)
Expand Down
4 changes: 2 additions & 2 deletions django/middleware/common.py
Expand Up @@ -130,14 +130,14 @@ def _is_ignorable_404(uri):
if getattr(settings, 'IGNORABLE_404_STARTS', ()):
import warnings
warnings.warn('The IGNORABLE_404_STARTS setting has been deprecated '
'in favor of IGNORABLE_404_URLS.', DeprecationWarning)
'in favor of IGNORABLE_404_URLS.', DeprecationWarning, stacklevel=2)
for start in settings.IGNORABLE_404_STARTS:
if uri.startswith(start):
return True
if getattr(settings, 'IGNORABLE_404_ENDS', ()):
import warnings
warnings.warn('The IGNORABLE_404_ENDS setting has been deprecated '
'in favor of IGNORABLE_404_URLS.', DeprecationWarning)
'in favor of IGNORABLE_404_URLS.', DeprecationWarning, stacklevel=2)
for end in settings.IGNORABLE_404_ENDS:
if uri.endswith(end):
return True
Expand Down
2 changes: 1 addition & 1 deletion django/template/defaultfilters.py
Expand Up @@ -55,7 +55,7 @@ def _dec(*args, **kwargs):
warnings.warn("Setting the %s attribute of a template filter "
"function is deprecated; use @register.filter(%s=%s) "
"instead" % (attr, attr, getattr(func, attr)),
DeprecationWarning)
DeprecationWarning, stacklevel=2)
setattr(_dec, attr, getattr(func, attr))

return wraps(func)(_dec)
Expand Down
2 changes: 1 addition & 1 deletion django/utils/copycompat.py
Expand Up @@ -7,7 +7,7 @@
import warnings

warnings.warn("django.utils.copycompat is deprecated; use the native copy module instead",
DeprecationWarning)
DeprecationWarning, stacklevel=2)

# Monkeypatch copy's deepcopy registry to handle functions correctly.
if (hasattr(copy, '_deepcopy_dispatch') and types.FunctionType not in copy._deepcopy_dispatch):
Expand Down
2 changes: 1 addition & 1 deletion django/utils/hashcompat.py
Expand Up @@ -6,7 +6,7 @@

import warnings
warnings.warn("django.utils.hashcompat is deprecated; use hashlib instead",
DeprecationWarning)
DeprecationWarning, stacklevel=2)

import hashlib
md5_constructor = hashlib.md5
Expand Down
4 changes: 2 additions & 2 deletions django/utils/itercompat.py
Expand Up @@ -24,10 +24,10 @@ def product(*args, **kwds):

def all(iterable):
warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead",
DeprecationWarning)
DeprecationWarning, stacklevel=2)
return builtins.all(iterable)

def any(iterable):
warnings.warn("django.utils.itercompat.any is deprecated; use the native version instead",
DeprecationWarning)
DeprecationWarning, stacklevel=2)
return builtins.any(iterable)
4 changes: 2 additions & 2 deletions django/utils/text.py
Expand Up @@ -211,14 +211,14 @@ def _html_words(self, length, truncate):

def truncate_words(s, num, end_text='...'):
warnings.warn('This function has been deprecated. Use the Truncator class '
'in django.utils.text instead.', category=DeprecationWarning)
'in django.utils.text instead.', category=DeprecationWarning, stacklevel=2)
truncate = end_text and ' %s' % end_text or ''
return Truncator(s).words(num, truncate=truncate)
truncate_words = allow_lazy(truncate_words, six.text_type)

def truncate_html_words(s, num, end_text='...'):
warnings.warn('This function has been deprecated. Use the Truncator class '
'in django.utils.text instead.', category=DeprecationWarning)
'in django.utils.text instead.', category=DeprecationWarning, stacklevel=2)
truncate = end_text and ' %s' % end_text or ''
return Truncator(s).words(num, truncate=truncate, html=True)
truncate_html_words = allow_lazy(truncate_html_words, six.text_type)
Expand Down
4 changes: 2 additions & 2 deletions django/utils/unittest/case.py
Expand Up @@ -339,15 +339,15 @@ def run(self, result=None):
addExpectedFailure(self, e.exc_info)
else:
warnings.warn("Use of a TestResult without an addExpectedFailure method is deprecated",
DeprecationWarning)
DeprecationWarning, stacklevel=2)
result.addSuccess(self)
except _UnexpectedSuccess:
addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
if addUnexpectedSuccess is not None:
addUnexpectedSuccess(self)
else:
warnings.warn("Use of a TestResult without an addUnexpectedSuccess method is deprecated",
DeprecationWarning)
DeprecationWarning, stacklevel=2)
result.addFailure(self, sys.exc_info())
except SkipTest, e:
self._addSkip(result, str(e))
Expand Down
4 changes: 2 additions & 2 deletions django/views/decorators/csrf.py
Expand Up @@ -55,15 +55,15 @@ def csrf_response_exempt(view_func):
"""
warnings.warn("csrf_response_exempt is deprecated. It no longer performs a "
"function, and calls to it can be removed.",
DeprecationWarning)
DeprecationWarning, stacklevel=2)
return view_func

def csrf_view_exempt(view_func):
"""
Marks a view function as being exempt from CSRF view protection.
"""
warnings.warn("csrf_view_exempt is deprecated. Use csrf_exempt instead.",
DeprecationWarning)
DeprecationWarning, stacklevel=2)
return csrf_exempt(view_func)

def csrf_exempt(view_func):
Expand Down

0 comments on commit b9d12f1

Please sign in to comment.