mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Advanced pending deprecation warnings.
Also added stacklevel argument, fixed #18127.
This commit is contained in:
@@ -15,5 +15,5 @@ if __name__ == "__main__":
|
||||
warnings.warn(
|
||||
"The `daily_cleanup` script has been deprecated "
|
||||
"in favor of `django-admin.py clearsessions`.",
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning)
|
||||
management.call_command('clearsessions')
|
||||
|
||||
@@ -139,7 +139,7 @@ class Settings(BaseSettings):
|
||||
isinstance(setting_value, six.string_types):
|
||||
warnings.warn("The %s setting must be a tuple. Please fix your "
|
||||
"settings, as auto-correction is now deprecated." % setting,
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
setting_value = (setting_value,) # In case the user forgot the comma.
|
||||
setattr(self, setting, setting_value)
|
||||
|
||||
|
||||
@@ -427,7 +427,7 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin):
|
||||
SiteProfileNotAvailable if this site does not allow profiles.
|
||||
"""
|
||||
warnings.warn("The use of AUTH_PROFILE_MODULE to define user profiles has been deprecated.",
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
if not hasattr(self, '_profile_cache'):
|
||||
from django.conf import settings
|
||||
if not getattr(settings, 'AUTH_PROFILE_MODULE', False):
|
||||
|
||||
@@ -7,5 +7,5 @@ class Command(clearsessions.Command):
|
||||
def handle_noargs(self, **options):
|
||||
warnings.warn(
|
||||
"The `cleanup` command has been deprecated in favor of `clearsessions`.",
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning)
|
||||
super(Command, self).handle_noargs(**options)
|
||||
|
||||
@@ -703,7 +703,7 @@ class QuerySet(object):
|
||||
"""
|
||||
if 'depth' in kwargs:
|
||||
warnings.warn('The "depth" keyword argument has been deprecated.\n'
|
||||
'Use related field names instead.', PendingDeprecationWarning)
|
||||
'Use related field names instead.', DeprecationWarning, stacklevel=2)
|
||||
depth = kwargs.pop('depth', 0)
|
||||
if kwargs:
|
||||
raise TypeError('Unexpected keyword arguments to select_related: %s'
|
||||
|
||||
@@ -42,7 +42,8 @@ class HttpResponseBase(six.Iterator):
|
||||
self._closable_objects = []
|
||||
if mimetype:
|
||||
warnings.warn("Using mimetype keyword argument is deprecated, use"
|
||||
" content_type instead", PendingDeprecationWarning)
|
||||
" content_type instead",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
content_type = mimetype
|
||||
if not content_type:
|
||||
content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
|
||||
@@ -296,7 +297,7 @@ class HttpResponse(HttpResponseBase):
|
||||
'Creating streaming responses with `HttpResponse` is '
|
||||
'deprecated. Use `StreamingHttpResponse` instead '
|
||||
'if you need the streaming behavior.',
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
if not hasattr(self, '_iterator'):
|
||||
self._iterator = iter(self._container)
|
||||
return self
|
||||
@@ -352,14 +353,14 @@ class CompatibleStreamingHttpResponse(StreamingHttpResponse):
|
||||
|
||||
These responses will stream only if no middleware attempts to access the
|
||||
`content` attribute. Otherwise, they will behave like a regular response,
|
||||
and raise a `PendingDeprecationWarning`.
|
||||
and raise a `DeprecationWarning`.
|
||||
"""
|
||||
@property
|
||||
def content(self):
|
||||
warnings.warn(
|
||||
'Accessing the `content` attribute on a streaming response is '
|
||||
'deprecated. Use the `streaming_content` attribute instead.',
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
content = b''.join(self)
|
||||
self.streaming_content = [content]
|
||||
return content
|
||||
@@ -369,7 +370,7 @@ class CompatibleStreamingHttpResponse(StreamingHttpResponse):
|
||||
warnings.warn(
|
||||
'Accessing the `content` attribute on a streaming response is '
|
||||
'deprecated. Use the `streaming_content` attribute instead.',
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
self.streaming_content = [content]
|
||||
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ class SortedDict(dict):
|
||||
# using collections.OrderedDict (Python 2.7 and up), which we'll
|
||||
# eventually switch to
|
||||
warnings.warn(
|
||||
"SortedDict.value_for_index is deprecated", PendingDeprecationWarning,
|
||||
"SortedDict.value_for_index is deprecated", DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return self[self.keyOrder[index]]
|
||||
@@ -225,7 +225,7 @@ class SortedDict(dict):
|
||||
def insert(self, index, key, value):
|
||||
"""Inserts the key, value pair before the item with the given index."""
|
||||
warnings.warn(
|
||||
"SortedDict.insert is deprecated", PendingDeprecationWarning,
|
||||
"SortedDict.insert is deprecated", DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
if key in self.keyOrder:
|
||||
|
||||
@@ -36,7 +36,7 @@ class StrAndUnicode(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn("StrAndUnicode is deprecated. Define a __str__ method "
|
||||
"and apply the @python_2_unicode_compatible decorator "
|
||||
"instead.", PendingDeprecationWarning, stacklevel=2)
|
||||
"instead.", DeprecationWarning, stacklevel=2)
|
||||
super(StrAndUnicode, self).__init__(*args, **kwargs)
|
||||
|
||||
if six.PY3:
|
||||
|
||||
@@ -19,5 +19,5 @@ def is_iterable(x):
|
||||
|
||||
def product(*args, **kwds):
|
||||
warnings.warn("django.utils.itercompat.product is deprecated; use the native version instead",
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
return itertools.product(*args, **kwds)
|
||||
|
||||
@@ -9,7 +9,7 @@ from __future__ import absolute_import
|
||||
|
||||
import warnings
|
||||
warnings.warn("django.utils.simplejson is deprecated; use json instead.",
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
|
||||
try:
|
||||
import simplejson
|
||||
|
||||
Reference in New Issue
Block a user