Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
wants to merge 3 commits into from

2 participants

@nmartini

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

@aaugustin
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!

@aaugustin aaugustin closed this
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.
View
4 django/conf/__init__.py
@@ -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.")
@@ -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"
View
2  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)
View
2  django/contrib/admin/templatetags/adminmedia.py
@@ -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")
View
2  django/contrib/databrowse/__init__.py
@@ -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)
View
2  django/contrib/formtools/wizard/legacy.py
@@ -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)
View
2  django/contrib/localflavor/uk/forms.py
@@ -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
View
2  django/contrib/localflavor/uk/uk_regions.py
@@ -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
View
4 django/core/management/__init__.py
@@ -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
@@ -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)
View
4 django/middleware/common.py
@@ -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
View
2  django/template/defaultfilters.py
@@ -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)
View
2  django/utils/copycompat.py
@@ -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):
View
2  django/utils/hashcompat.py
@@ -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
View
4 django/utils/itercompat.py
@@ -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)
View
4 django/utils/text.py
@@ -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)
View
4 django/utils/unittest/case.py
@@ -339,7 +339,7 @@ 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)
@@ -347,7 +347,7 @@ def run(self, result=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))
View
4 django/views/decorators/csrf.py
@@ -55,7 +55,7 @@ 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):
@@ -63,7 +63,7 @@ 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):
Something went wrong with that request. Please try again.