Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Advanced pending deprecation warnings.

Also added stacklevel argument, fixed #18127.
  • Loading branch information...
commit ef017a5f00d9e84059e00e8fea123be51b293f75 1 parent 1308293
@aaugustin aaugustin authored
View
2  django/bin/daily_cleanup.py
@@ -15,5 +15,5 @@
warnings.warn(
"The `daily_cleanup` script has been deprecated "
"in favor of `django-admin.py clearsessions`.",
- PendingDeprecationWarning)
+ DeprecationWarning)
management.call_command('clearsessions')
View
2  django/conf/__init__.py
@@ -139,7 +139,7 @@ def __init__(self, settings_module):
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)
View
2  django/contrib/auth/models.py
@@ -427,7 +427,7 @@ def get_profile(self):
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):
View
2  django/core/management/commands/cleanup.py
@@ -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)
View
2  django/db/models/query.py
@@ -703,7 +703,7 @@ def select_related(self, *fields, **kwargs):
"""
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'
View
11 django/http/response.py
@@ -42,7 +42,8 @@ def __init__(self, content_type=None, status=None, mimetype=None):
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 @@ def __iter__(self):
'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 @@ def content(self, content):
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]
View
4 django/utils/datastructures.py
@@ -217,7 +217,7 @@ def value_for_index(self, index):
# 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 @@ def value_for_index(self, index):
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:
View
2  django/utils/encoding.py
@@ -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:
View
2  django/utils/itercompat.py
@@ -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)
View
2  django/utils/simplejson.py
@@ -9,7 +9,7 @@
import warnings
warnings.warn("django.utils.simplejson is deprecated; use json instead.",
- PendingDeprecationWarning)
+ DeprecationWarning, stacklevel=2)
try:
import simplejson
View
12 tests/regressiontests/httpwrappers/tests.py
@@ -326,13 +326,13 @@ def test_iter_content(self):
r = HttpResponse()
r.content = ['1', '2', 3, '\u079e']
with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter("always", PendingDeprecationWarning)
+ warnings.simplefilter("always", DeprecationWarning)
my_iter = iter(r)
- self.assertEqual(w[0].category, PendingDeprecationWarning)
+ self.assertEqual(w[0].category, DeprecationWarning)
with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter("always", PendingDeprecationWarning)
+ warnings.simplefilter("always", DeprecationWarning)
result = list(my_iter)
- self.assertEqual(w[0].category, PendingDeprecationWarning)
+ self.assertEqual(w[0].category, DeprecationWarning)
#'\xde\x9e' == unichr(1950).encode('utf-8')
self.assertEqual(result, [b'1', b'2', b'3', b'\xde\x9e'])
self.assertEqual(r.content, b'123\xde\x9e')
@@ -360,7 +360,7 @@ def test_iter_content(self):
# XXX change this when the deprecation completes in HttpResponse
r = HttpResponse(iter(['hello', 'world']))
with warnings.catch_warnings():
- warnings.simplefilter("ignore", PendingDeprecationWarning)
+ warnings.simplefilter("ignore", DeprecationWarning)
self.assertEqual(b''.join(r), b'helloworld')
self.assertEqual(r.content, b'') # not the expected result!
@@ -497,7 +497,7 @@ def test_response(self):
r = HttpResponse(file1)
self.assertFalse(file1.closed)
with warnings.catch_warnings():
- warnings.simplefilter("ignore", PendingDeprecationWarning)
+ warnings.simplefilter("ignore", DeprecationWarning)
list(r)
self.assertFalse(file1.closed)
r.close()
View
4 tests/regressiontests/utils/datastructures.py
@@ -139,14 +139,14 @@ def test_insert(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
d.insert(0, "hello", "world")
- assert w[0].category is PendingDeprecationWarning
+ assert w[0].category is DeprecationWarning
def test_value_for_index(self):
d = SortedDict({"a": 3})
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
self.assertEqual(d.value_for_index(0), 3)
- assert w[0].category is PendingDeprecationWarning
+ assert w[0].category is DeprecationWarning
class MergeDictTests(SimpleTestCase):
Please sign in to comment.
Something went wrong with that request. Please try again.