diff --git a/django/bin/daily_cleanup.py b/django/bin/daily_cleanup.py index ac3de00f2c..5a2ce210f4 100755 --- a/django/bin/daily_cleanup.py +++ b/django/bin/daily_cleanup.py @@ -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') diff --git a/django/conf/__init__.py b/django/conf/__init__.py index ccf7a94af6..bbcc16e120 100644 --- a/django/conf/__init__.py +++ b/django/conf/__init__.py @@ -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) diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 7d62810923..6f20981ca6 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -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): diff --git a/django/core/management/commands/cleanup.py b/django/core/management/commands/cleanup.py index f83c64be8f..e158ebb541 100644 --- a/django/core/management/commands/cleanup.py +++ b/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) diff --git a/django/db/models/query.py b/django/db/models/query.py index f56d5d2842..ee58a77886 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -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' diff --git a/django/http/response.py b/django/http/response.py index df0a955b18..d667ba6eed 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -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] diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index f81fb88a19..64c218fe43 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -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: diff --git a/django/utils/encoding.py b/django/utils/encoding.py index 15215849b2..68929cc0e5 100644 --- a/django/utils/encoding.py +++ b/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: diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py index fe8f8b9b46..e7ea326536 100644 --- a/django/utils/itercompat.py +++ b/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) diff --git a/django/utils/simplejson.py b/django/utils/simplejson.py index a851a4f8ef..d4032a6b34 100644 --- a/django/utils/simplejson.py +++ b/django/utils/simplejson.py @@ -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 diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py index d26a728e7b..67172d963c 100644 --- a/tests/regressiontests/httpwrappers/tests.py +++ b/tests/regressiontests/httpwrappers/tests.py @@ -326,13 +326,13 @@ class HttpResponseTests(unittest.TestCase): 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 @@ class HttpResponseTests(unittest.TestCase): # 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 @@ class FileCloseTests(TestCase): 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() diff --git a/tests/regressiontests/utils/datastructures.py b/tests/regressiontests/utils/datastructures.py index f65fc5c770..3161c04f97 100644 --- a/tests/regressiontests/utils/datastructures.py +++ b/tests/regressiontests/utils/datastructures.py @@ -139,14 +139,14 @@ class SortedDictTests(SimpleTestCase): 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):