Skip to content

Commit ef017a5

Browse files
committed
Advanced pending deprecation warnings.
Also added stacklevel argument, fixed django#18127.
1 parent 1308293 commit ef017a5

File tree

12 files changed

+24
-23
lines changed

12 files changed

+24
-23
lines changed

django/bin/daily_cleanup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
warnings.warn(
1616
"The `daily_cleanup` script has been deprecated "
1717
"in favor of `django-admin.py clearsessions`.",
18-
PendingDeprecationWarning)
18+
DeprecationWarning)
1919
management.call_command('clearsessions')

django/conf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def __init__(self, settings_module):
139139
isinstance(setting_value, six.string_types):
140140
warnings.warn("The %s setting must be a tuple. Please fix your "
141141
"settings, as auto-correction is now deprecated." % setting,
142-
PendingDeprecationWarning)
142+
DeprecationWarning, stacklevel=2)
143143
setting_value = (setting_value,) # In case the user forgot the comma.
144144
setattr(self, setting, setting_value)
145145

django/contrib/auth/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def get_profile(self):
427427
SiteProfileNotAvailable if this site does not allow profiles.
428428
"""
429429
warnings.warn("The use of AUTH_PROFILE_MODULE to define user profiles has been deprecated.",
430-
PendingDeprecationWarning)
430+
DeprecationWarning, stacklevel=2)
431431
if not hasattr(self, '_profile_cache'):
432432
from django.conf import settings
433433
if not getattr(settings, 'AUTH_PROFILE_MODULE', False):

django/core/management/commands/cleanup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ class Command(clearsessions.Command):
77
def handle_noargs(self, **options):
88
warnings.warn(
99
"The `cleanup` command has been deprecated in favor of `clearsessions`.",
10-
PendingDeprecationWarning)
10+
DeprecationWarning)
1111
super(Command, self).handle_noargs(**options)

django/db/models/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def select_related(self, *fields, **kwargs):
703703
"""
704704
if 'depth' in kwargs:
705705
warnings.warn('The "depth" keyword argument has been deprecated.\n'
706-
'Use related field names instead.', PendingDeprecationWarning)
706+
'Use related field names instead.', DeprecationWarning, stacklevel=2)
707707
depth = kwargs.pop('depth', 0)
708708
if kwargs:
709709
raise TypeError('Unexpected keyword arguments to select_related: %s'

django/http/response.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def __init__(self, content_type=None, status=None, mimetype=None):
4242
self._closable_objects = []
4343
if mimetype:
4444
warnings.warn("Using mimetype keyword argument is deprecated, use"
45-
" content_type instead", PendingDeprecationWarning)
45+
" content_type instead",
46+
DeprecationWarning, stacklevel=2)
4647
content_type = mimetype
4748
if not content_type:
4849
content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
@@ -296,7 +297,7 @@ def __iter__(self):
296297
'Creating streaming responses with `HttpResponse` is '
297298
'deprecated. Use `StreamingHttpResponse` instead '
298299
'if you need the streaming behavior.',
299-
PendingDeprecationWarning, stacklevel=2)
300+
DeprecationWarning, stacklevel=2)
300301
if not hasattr(self, '_iterator'):
301302
self._iterator = iter(self._container)
302303
return self
@@ -352,14 +353,14 @@ class CompatibleStreamingHttpResponse(StreamingHttpResponse):
352353
353354
These responses will stream only if no middleware attempts to access the
354355
`content` attribute. Otherwise, they will behave like a regular response,
355-
and raise a `PendingDeprecationWarning`.
356+
and raise a `DeprecationWarning`.
356357
"""
357358
@property
358359
def content(self):
359360
warnings.warn(
360361
'Accessing the `content` attribute on a streaming response is '
361362
'deprecated. Use the `streaming_content` attribute instead.',
362-
PendingDeprecationWarning)
363+
DeprecationWarning, stacklevel=2)
363364
content = b''.join(self)
364365
self.streaming_content = [content]
365366
return content
@@ -369,7 +370,7 @@ def content(self, content):
369370
warnings.warn(
370371
'Accessing the `content` attribute on a streaming response is '
371372
'deprecated. Use the `streaming_content` attribute instead.',
372-
PendingDeprecationWarning)
373+
DeprecationWarning, stacklevel=2)
373374
self.streaming_content = [content]
374375

375376

django/utils/datastructures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ def value_for_index(self, index):
217217
# using collections.OrderedDict (Python 2.7 and up), which we'll
218218
# eventually switch to
219219
warnings.warn(
220-
"SortedDict.value_for_index is deprecated", PendingDeprecationWarning,
220+
"SortedDict.value_for_index is deprecated", DeprecationWarning,
221221
stacklevel=2
222222
)
223223
return self[self.keyOrder[index]]
224224

225225
def insert(self, index, key, value):
226226
"""Inserts the key, value pair before the item with the given index."""
227227
warnings.warn(
228-
"SortedDict.insert is deprecated", PendingDeprecationWarning,
228+
"SortedDict.insert is deprecated", DeprecationWarning,
229229
stacklevel=2
230230
)
231231
if key in self.keyOrder:

django/utils/encoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class StrAndUnicode(object):
3636
def __init__(self, *args, **kwargs):
3737
warnings.warn("StrAndUnicode is deprecated. Define a __str__ method "
3838
"and apply the @python_2_unicode_compatible decorator "
39-
"instead.", PendingDeprecationWarning, stacklevel=2)
39+
"instead.", DeprecationWarning, stacklevel=2)
4040
super(StrAndUnicode, self).__init__(*args, **kwargs)
4141

4242
if six.PY3:

django/utils/itercompat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def is_iterable(x):
1919

2020
def product(*args, **kwds):
2121
warnings.warn("django.utils.itercompat.product is deprecated; use the native version instead",
22-
PendingDeprecationWarning)
22+
DeprecationWarning, stacklevel=2)
2323
return itertools.product(*args, **kwds)

django/utils/simplejson.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import warnings
1111
warnings.warn("django.utils.simplejson is deprecated; use json instead.",
12-
PendingDeprecationWarning)
12+
DeprecationWarning, stacklevel=2)
1313

1414
try:
1515
import simplejson

0 commit comments

Comments
 (0)