From 210d0489c5daad56b806f8165f9fe09fb3c2a019 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 26 Feb 2014 22:48:20 +0100 Subject: [PATCH] Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks Anssi Kääriäinen for the idea and Simon Charette for the review. --- django/apps/registry.py | 19 ++++++------- django/conf/urls/shortcut.py | 3 ++- django/contrib/admin/options.py | 27 ++++++++++--------- django/contrib/admin/util.py | 4 ++- django/contrib/admin/views/main.py | 10 +++---- django/contrib/admindocs/views.py | 3 ++- django/contrib/comments/__init__.py | 5 +++- .../contrib/comments/templatetags/comments.py | 4 +-- django/contrib/contenttypes/fields.py | 4 +-- django/contrib/contenttypes/generic.py | 3 ++- django/contrib/gis/db/backends/util.py | 4 ++- django/contrib/gis/sitemaps/views.py | 5 ++-- django/contrib/sites/models.py | 7 ++--- django/core/cache/__init__.py | 3 ++- django/core/cache/backends/memcached.py | 5 ++-- django/core/handlers/wsgi.py | 3 ++- django/core/management/base.py | 5 ++-- django/core/management/commands/dumpdata.py | 3 ++- django/core/management/commands/runfcgi.py | 3 ++- django/core/management/commands/syncdb.py | 4 ++- django/core/management/commands/validate.py | 3 ++- django/core/management/sql.py | 3 ++- django/core/serializers/base.py | 3 ++- django/db/__init__.py | 5 ++-- django/db/backends/__init__.py | 2 +- django/db/backends/creation.py | 3 ++- django/db/backends/util.py | 4 ++- django/db/models/__init__.py | 3 ++- django/db/models/base.py | 9 ++++--- django/db/models/fields/__init__.py | 3 ++- django/db/models/fields/related.py | 6 ++--- django/db/models/loading.py | 4 ++- django/db/models/manager.py | 6 ++--- django/db/models/options.py | 11 ++++---- django/db/models/sql/query.py | 11 ++++---- django/db/models/sql/where.py | 5 ++-- django/db/transaction.py | 15 ++++++----- django/db/utils.py | 5 ++-- django/forms/fields.py | 5 ++-- django/forms/forms.py | 7 ++--- django/forms/models.py | 12 +++++---- django/forms/util.py | 4 ++- django/forms/utils.py | 5 ++-- django/forms/widgets.py | 7 ++--- django/middleware/cache.py | 3 ++- django/middleware/common.py | 3 ++- django/middleware/doc.py | 5 +++- django/middleware/transaction.py | 3 ++- django/template/defaulttags.py | 5 ++-- django/templatetags/future.py | 5 ++-- django/test/_doctest.py | 6 +++-- django/test/simple.py | 3 ++- django/test/utils.py | 12 ++++----- django/utils/datastructures.py | 6 +++-- django/utils/deprecation.py | 8 ++++++ django/utils/dictconfig.py | 4 ++- django/utils/functional.py | 3 ++- django/utils/html.py | 7 ++--- django/utils/image.py | 3 ++- django/utils/importlib.py | 4 ++- django/utils/module_loading.py | 3 ++- django/utils/text.py | 3 ++- django/utils/translation/trans_real.py | 3 ++- django/utils/tzinfo.py | 7 ++--- django/utils/unittest.py | 4 ++- django/views/defaults.py | 3 ++- django/views/generic/edit.py | 5 ++-- .../writing-code/submitting-patches.txt | 10 +++---- docs/internals/release-process.txt | 13 +++++---- tests/defaultfilters/tests.py | 5 ++-- tests/deprecation/tests.py | 1 + tests/forms_tests/tests/test_widgets.py | 5 ++-- tests/generic_views/test_edit.py | 7 ++--- tests/httpwrappers/tests.py | 3 ++- tests/middleware/tests.py | 7 ++--- tests/model_forms/tests.py | 7 ++--- tests/model_forms_regress/tests.py | 7 ++--- tests/modeladmin/tests.py | 3 ++- tests/runtests.py | 11 +++++--- tests/template_tests/tests.py | 5 ++-- tests/utils_tests/test_html.py | 5 ++-- tests/utils_tests/test_module_loading.py | 5 ++-- tests/utils_tests/test_text.py | 5 ++-- tests/utils_tests/test_tzinfo.py | 4 ++- 84 files changed, 287 insertions(+), 189 deletions(-) diff --git a/django/apps/registry.py b/django/apps/registry.py index 601091cfb7..41095bd41e 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -6,6 +6,7 @@ import warnings from django.core.exceptions import ImproperlyConfigured from django.utils import lru_cache +from django.utils.deprecation import RemovedInDjango19Warning from django.utils._os import upath from .config import AppConfig @@ -156,7 +157,7 @@ class Apps(object): if app_mod: warnings.warn( "The app_mod argument of get_models is deprecated.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) app_label = app_mod.__name__.split('.')[-2] try: return list(self.get_app_config(app_label).get_models( @@ -328,7 +329,7 @@ class Apps(object): """ warnings.warn( "load_app(app_name) is deprecated.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) app_config = AppConfig.create(app_name) app_config.import_models(self.all_models[app_config.label]) self.app_configs[app_config.label] = app_config @@ -338,7 +339,7 @@ class Apps(object): def app_cache_ready(self): warnings.warn( "app_cache_ready() is deprecated in favor of the ready property.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) return self.ready def get_app(self, app_label): @@ -347,7 +348,7 @@ class Apps(object): """ warnings.warn( "get_app_config(app_label).models_module supersedes get_app(app_label).", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) try: models_module = self.get_app_config(app_label).models_module except LookupError as exc: @@ -364,7 +365,7 @@ class Apps(object): """ warnings.warn( "[a.models_module for a in get_app_configs()] supersedes get_apps().", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) app_configs = self.get_app_configs() return [app_config.models_module for app_config in app_configs if app_config.models_module is not None] @@ -375,7 +376,7 @@ class Apps(object): def get_app_package(self, app_label): warnings.warn( "get_app_config(label).name supersedes get_app_package(label).", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) return self._get_app_package(self.get_app(app_label)) def _get_app_path(self, app): @@ -388,7 +389,7 @@ class Apps(object): def get_app_path(self, app_label): warnings.warn( "get_app_config(label).path supersedes get_app_path(label).", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) return self._get_app_path(self.get_app(app_label)) def get_app_paths(self): @@ -400,7 +401,7 @@ class Apps(object): """ warnings.warn( "[a.path for a in get_app_configs()] supersedes get_app_paths().", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) self.check_ready() app_paths = [] for app in self.get_apps(): @@ -413,7 +414,7 @@ class Apps(object): """ warnings.warn( "register_models(app_label, *models) is deprecated.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) for model in models: self.register_model(app_label, model) diff --git a/django/conf/urls/shortcut.py b/django/conf/urls/shortcut.py index 08ecd90aa3..827c56dde4 100644 --- a/django/conf/urls/shortcut.py +++ b/django/conf/urls/shortcut.py @@ -1,9 +1,10 @@ import warnings from django.conf.urls import patterns +from django.utils.deprecation import RemovedInDjango18Warning warnings.warn("django.conf.urls.shortcut will be removed in Django 1.8.", - DeprecationWarning) + RemovedInDjango18Warning) urlpatterns = patterns('django.views', (r'^(?P\d+)/(?P.*)/$', 'defaults.shortcut'), diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index b4fa54af6c..c67c7dc7c8 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -18,7 +18,8 @@ from django.contrib.admin.templatetags.admin_static import static from django.contrib.admin.templatetags.admin_urls import add_preserved_filters from django.contrib.auth import get_permission_codename from django.core import checks -from django.core.exceptions import PermissionDenied, ValidationError, FieldError, ImproperlyConfigured +from django.core.exceptions import (PermissionDenied, ValidationError, + FieldError, ImproperlyConfigured) from django.core.paginator import Paginator from django.core.urlresolvers import reverse from django.db import models, transaction, router @@ -35,9 +36,9 @@ from django.shortcuts import get_object_or_404 from django.template.response import SimpleTemplateResponse, TemplateResponse from django.utils import six from django.utils.decorators import method_decorator -from django.utils.deprecation import RenameMethodsBase -from django.utils.encoding import force_text -from django.utils.encoding import python_2_unicode_compatible +from django.utils.deprecation import (RenameMethodsBase, + RemovedInDjango18Warning, RemovedInDjango19Warning) +from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.html import escape, escapejs from django.utils.http import urlencode from django.utils.text import capfirst, get_text_list @@ -93,7 +94,7 @@ csrf_protect_m = method_decorator(csrf_protect) class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase): renamed_methods = ( - ('queryset', 'get_queryset', DeprecationWarning), + ('queryset', 'get_queryset', RemovedInDjango18Warning), ) @@ -125,7 +126,7 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)): def validate(cls, model): warnings.warn( 'ModelAdmin.validate() is deprecated. Use "check()" instead.', - PendingDeprecationWarning) + RemovedInDjango19Warning) if cls.validator_class: validator = cls.validator_class() else: @@ -139,7 +140,7 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)): 'ModelAdmin.validator_class is deprecated. ' 'ModeAdmin validators must be converted to use ' 'the system check framework.', - PendingDeprecationWarning) + RemovedInDjango19Warning) validator = cls.validator_class() try: validator.validate(cls, model) @@ -306,7 +307,7 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)): warnings.warn( "ModelAdmin.declared_fieldsets is deprecated and " "will be removed in Django 1.9.", - PendingDeprecationWarning, stacklevel=2 + RemovedInDjango19Warning, stacklevel=2 ) if self.fieldsets: @@ -332,11 +333,11 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)): with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") declared_fieldsets = self.declared_fieldsets - if len(w) != 1 or not issubclass(w[0].category, PendingDeprecationWarning): + if len(w) != 1 or not issubclass(w[0].category, RemovedInDjango19Warning): warnings.warn( "ModelAdmin.declared_fieldsets is deprecated and " "will be removed in Django 1.9.", - PendingDeprecationWarning + RemovedInDjango19Warning ) if declared_fieldsets: return declared_fieldsets @@ -695,7 +696,7 @@ class ModelAdmin(BaseModelAdmin): warnings.warn( "ModelAdmin.get_formsets() is deprecated and will be removed in " "Django 1.9. Use ModelAdmin.get_formsets_with_inlines() instead.", - PendingDeprecationWarning, stacklevel=2 + RemovedInDjango19Warning, stacklevel=2 ) return self._get_formsets(request, obj) @@ -711,11 +712,11 @@ class ModelAdmin(BaseModelAdmin): warnings.simplefilter("always") formsets = self.get_formsets(request, obj) - if len(w) != 1 or not issubclass(w[0].category, PendingDeprecationWarning): + if len(w) != 1 or not issubclass(w[0].category, RemovedInDjango19Warning): warnings.warn( "ModelAdmin.get_formsets() is deprecated and will be removed in " "Django 1.9. Use ModelAdmin.get_formsets_with_inlines() instead.", - PendingDeprecationWarning + RemovedInDjango19Warning ) if formsets: zipped = zip(formsets, self.get_inline_instances(request, None)) diff --git a/django/contrib/admin/util.py b/django/contrib/admin/util.py index a6ef5745ae..416b75e7b2 100644 --- a/django/contrib/admin/util.py +++ b/django/contrib/admin/util.py @@ -1,7 +1,9 @@ import warnings +from django.utils.deprecation import RemovedInDjango19Warning + warnings.warn( "The django.contrib.admin.util module has been renamed. " - "Use django.contrib.admin.utils instead.", PendingDeprecationWarning) + "Use django.contrib.admin.utils instead.", RemovedInDjango19Warning) from django.contrib.admin.utils import * # NOQA diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index c22225927c..15f5c57206 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -8,7 +8,7 @@ from django.core.urlresolvers import reverse from django.db import models from django.db.models.fields import FieldDoesNotExist from django.utils import six -from django.utils.deprecation import RenameMethodsBase +from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.encoding import force_text from django.utils.translation import ugettext, ugettext_lazy from django.utils.http import urlencode @@ -51,7 +51,7 @@ def _is_changelist_popup(request): warnings.warn( "The `%s` GET parameter has been renamed to `%s`." % (IS_LEGACY_POPUP_VAR, IS_POPUP_VAR), - DeprecationWarning, 2) + RemovedInDjango18Warning, 2) return True return False @@ -59,7 +59,7 @@ def _is_changelist_popup(request): class RenameChangeListMethods(RenameMethodsBase): renamed_methods = ( - ('get_query_set', 'get_queryset', DeprecationWarning), + ('get_query_set', 'get_queryset', RemovedInDjango18Warning), ) @@ -114,14 +114,14 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)): def root_query_set(self): warnings.warn("`ChangeList.root_query_set` is deprecated, " "use `root_queryset` instead.", - DeprecationWarning, 2) + RemovedInDjango18Warning, 2) return self.root_queryset @property def query_set(self): warnings.warn("`ChangeList.query_set` is deprecated, " "use `queryset` instead.", - DeprecationWarning, 2) + RemovedInDjango18Warning, 2) return self.queryset def get_filters_params(self, params=None): diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index 75f2c13060..6cb46beaf5 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -15,6 +15,7 @@ from django.http import Http404 from django.core import urlresolvers from django.contrib.admindocs import utils from django.utils.decorators import method_decorator +from django.utils.deprecation import RemovedInDjango18Warning from django.utils._os import upath from django.utils import six from django.utils.translation import ugettext as _ @@ -25,7 +26,7 @@ MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_') if getattr(settings, 'ADMIN_FOR', None): warnings.warn('The ADMIN_FOR setting has been removed, you can remove ' - 'this setting from your configuration.', DeprecationWarning, + 'this setting from your configuration.', RemovedInDjango18Warning, stacklevel=2) diff --git a/django/contrib/comments/__init__.py b/django/contrib/comments/__init__.py index a62fff1b56..06ede3a8cc 100644 --- a/django/contrib/comments/__init__.py +++ b/django/contrib/comments/__init__.py @@ -1,13 +1,16 @@ from importlib import import_module import warnings + from django.apps import apps as django_apps from django.conf import settings from django.core import urlresolvers from django.core.exceptions import ImproperlyConfigured from django.contrib.comments.models import Comment from django.contrib.comments.forms import CommentForm +from django.utils.deprecation import RemovedInDjango18Warning -warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", DeprecationWarning) + +warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", RemovedInDjango18Warning) DEFAULT_COMMENTS_APP = 'django.contrib.comments' diff --git a/django/contrib/comments/templatetags/comments.py b/django/contrib/comments/templatetags/comments.py index 476612c75d..02001de204 100644 --- a/django/contrib/comments/templatetags/comments.py +++ b/django/contrib/comments/templatetags/comments.py @@ -4,7 +4,7 @@ from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.contrib import comments from django.utils import six -from django.utils.deprecation import RenameMethodsBase +from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.encoding import smart_text register = template.Library() @@ -12,7 +12,7 @@ register = template.Library() class RenameBaseCommentNodeMethods(RenameMethodsBase): renamed_methods = ( - ('get_query_set', 'get_queryset', DeprecationWarning), + ('get_query_set', 'get_queryset', RemovedInDjango18Warning), ) diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py index db45b79fb4..7c27d5960b 100644 --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -13,13 +13,13 @@ from django.db.models.related import PathInfo from django.db.models.sql.datastructures import Col from django.contrib.contenttypes.models import ContentType from django.utils import six -from django.utils.deprecation import RenameMethodsBase +from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.encoding import smart_text, python_2_unicode_compatible class RenameGenericForeignKeyMethods(RenameMethodsBase): renamed_methods = ( - ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning), + ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning), ) diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py index 9da4ba1f19..19622d33d8 100644 --- a/django/contrib/contenttypes/generic.py +++ b/django/contrib/contenttypes/generic.py @@ -2,11 +2,12 @@ from __future__ import unicode_literals import warnings +from django.utils.deprecation import RemovedInDjango19Warning warnings.warn( ('django.contrib.contenttypes.generic is deprecated and will be removed in ' 'Django 1.9. Its contents have been moved to the fields, forms, and admin ' - 'submodules of django.contrib.contenttypes.'), PendingDeprecationWarning, stacklevel=2 + 'submodules of django.contrib.contenttypes.'), RemovedInDjango19Warning, stacklevel=2 ) from django.contrib.contenttypes.admin import ( # NOQA diff --git a/django/contrib/gis/db/backends/util.py b/django/contrib/gis/db/backends/util.py index fc8ee994c7..6be5bc256e 100644 --- a/django/contrib/gis/db/backends/util.py +++ b/django/contrib/gis/db/backends/util.py @@ -1,7 +1,9 @@ import warnings +from django.utils.deprecation import RemovedInDjango19Warning + warnings.warn( "The django.contrib.gis.db.backends.util module has been renamed. " - "Use django.contrib.gis.db.backends.utils instead.", PendingDeprecationWarning) + "Use django.contrib.gis.db.backends.utils instead.", RemovedInDjango19Warning) from django.contrib.gis.db.backends.utils import * # NOQA diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py index ebfecc5b26..be99516689 100644 --- a/django/contrib/gis/sitemaps/views.py +++ b/django/contrib/gis/sitemaps/views.py @@ -12,6 +12,7 @@ from django.contrib.gis.db.models.fields import GeometryField from django.db import connections, DEFAULT_DB_ALIAS from django.db.models.fields import FieldDoesNotExist from django.utils import six +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.translation import ugettext as _ from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz @@ -23,7 +24,7 @@ def index(request, sitemaps): for resolving geographic section sitemap URLs. """ warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from " - "django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2) + "django.contrib.sitemaps instead", RemovedInDjango18Warning, stacklevel=2) current_site = get_current_site(request) sites = [] protocol = request.scheme @@ -48,7 +49,7 @@ def sitemap(request, sitemaps, section=None): elements defined by Google. """ warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from " - "django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2) + "django.contrib.sitemaps instead", RemovedInDjango18Warning, stacklevel=2) maps, urls = [], [] if section is not None: if section not in sitemaps: diff --git a/django/contrib/sites/models.py b/django/contrib/sites/models.py index 8f72e1a11c..0e80d9107a 100644 --- a/django/contrib/sites/models.py +++ b/django/contrib/sites/models.py @@ -6,8 +6,9 @@ import warnings from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.db.models.signals import pre_save, pre_delete -from django.utils.translation import ugettext_lazy as _ +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ from .requests import RequestSite as RealRequestSite from .shortcuts import get_current_site as real_get_current_site @@ -82,14 +83,14 @@ class RequestSite(RealRequestSite): def __init__(self, *args, **kwargs): warnings.warn( "Please import RequestSite from django.contrib.sites.requests.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) super(RequestSite, self).__init__(*args, **kwargs) def get_current_site(request): warnings.warn( "Please import get_current_site from django.contrib.sites.shortcuts.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) return real_get_current_site(request) diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index 603086a39c..63b739f1de 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -20,6 +20,7 @@ from django.core import signals from django.core.cache.backends.base import ( InvalidCacheBackendError, CacheKeyWarning, BaseCache) from django.core.exceptions import ImproperlyConfigured +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.module_loading import import_string @@ -52,7 +53,7 @@ def get_cache(backend, **kwargs): """ warnings.warn("'get_cache' is deprecated in favor of 'caches'.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) cache = _create_cache(backend, **kwargs) # Some caches -- python-memcached in particular -- need to do a cleanup at the # end of a request cycle. If not implemented in a particular backend diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py index 216ceb04e1..0c094f0fde 100644 --- a/django/core/cache/backends/memcached.py +++ b/django/core/cache/backends/memcached.py @@ -4,16 +4,15 @@ import time import pickle from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT - from django.utils import six -from django.utils.deprecation import RenameMethodsBase +from django.utils.deprecation import RenameMethodsBase, RemovedInDjango19Warning from django.utils.encoding import force_str from django.utils.functional import cached_property class BaseMemcachedCacheMethods(RenameMethodsBase): renamed_methods = ( - ('_get_memcache_timeout', 'get_backend_timeout', PendingDeprecationWarning), + ('_get_memcache_timeout', 'get_backend_timeout', RemovedInDjango19Warning), ) diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index 185b8e93f1..846c48e867 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -14,6 +14,7 @@ from django.core import signals from django.core.handlers import base from django.core.urlresolvers import set_script_prefix from django.utils import datastructures +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_str, force_text from django.utils.functional import cached_property from django.utils import six @@ -118,7 +119,7 @@ class WSGIRequest(http.HttpRequest): def _get_request(self): warnings.warn('`request.REQUEST` is deprecated, use `request.GET` or ' - '`request.POST` instead.', PendingDeprecationWarning, 2) + '`request.POST` instead.', RemovedInDjango19Warning, 2) if not hasattr(self, '_request'): self._request = datastructures.MergeDict(self.POST, self.GET) return self._request diff --git a/django/core/management/base.py b/django/core/management/base.py index b07c1cbd26..5116b417f4 100644 --- a/django/core/management/base.py +++ b/django/core/management/base.py @@ -17,6 +17,7 @@ import django from django.core import checks from django.core.exceptions import ImproperlyConfigured from django.core.management.color import color_style, no_style +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_str @@ -219,7 +220,7 @@ class BaseCommand(object): warnings.warn( '"requires_model_validation" is deprecated ' 'in favor of "requires_system_checks".', - PendingDeprecationWarning) + RemovedInDjango19Warning) if has_old_option and has_new_option: raise ImproperlyConfigured( 'Command %s defines both "requires_model_validation" ' @@ -467,7 +468,7 @@ class AppCommand(BaseCommand): warnings.warn( "AppCommand.handle_app() is superseded by " "AppCommand.handle_app_config().", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) if app_config.models_module is None: raise CommandError( "AppCommand cannot handle app '%s' in legacy mode " diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index 8150219cbd..ae93e34e48 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -7,6 +7,7 @@ from django.apps import apps from django.core.management.base import BaseCommand, CommandError from django.core import serializers from django.db import router, DEFAULT_DB_ALIAS +from django.utils.deprecation import RemovedInDjango19Warning class Command(BaseCommand): @@ -50,7 +51,7 @@ class Command(BaseCommand): use_natural_keys = options.get('use_natural_keys') if use_natural_keys: warnings.warn("``--natural`` is deprecated; use ``--natural-foreign`` instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) use_natural_foreign_keys = options.get('use_natural_foreign_keys') or use_natural_keys use_natural_primary_keys = options.get('use_natural_primary_keys') use_base_manager = options.get('use_base_manager') diff --git a/django/core/management/commands/runfcgi.py b/django/core/management/commands/runfcgi.py index cf4a010bc0..e701a64fba 100644 --- a/django/core/management/commands/runfcgi.py +++ b/django/core/management/commands/runfcgi.py @@ -1,6 +1,7 @@ import warnings from django.core.management.base import BaseCommand +from django.utils.deprecation import RemovedInDjango19Warning class Command(BaseCommand): @@ -10,7 +11,7 @@ class Command(BaseCommand): def handle(self, *args, **options): warnings.warn( "FastCGI support has been deprecated and will be removed in Django 1.9.", - PendingDeprecationWarning) + RemovedInDjango19Warning) from django.conf import settings from django.utils import translation diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py index 17ea51f4d5..e6ca565ca2 100644 --- a/django/core/management/commands/syncdb.py +++ b/django/core/management/commands/syncdb.py @@ -1,8 +1,10 @@ import warnings from optparse import make_option + from django.db import DEFAULT_DB_ALIAS from django.core.management import call_command from django.core.management.base import NoArgsCommand +from django.utils.deprecation import RemovedInDjango19Warning class Command(NoArgsCommand): @@ -18,5 +20,5 @@ class Command(NoArgsCommand): help = "Deprecated - use 'migrate' instead." def handle_noargs(self, **options): - warnings.warn("The syncdb command will be removed in Django 1.9", PendingDeprecationWarning) + warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning) call_command("migrate", **options) diff --git a/django/core/management/commands/validate.py b/django/core/management/commands/validate.py index 6b894c6440..490fe6c26f 100644 --- a/django/core/management/commands/validate.py +++ b/django/core/management/commands/validate.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import warnings from django.core.management.commands.check import Command as CheckCommand +from django.utils.deprecation import RemovedInDjango19Warning class Command(CheckCommand): @@ -11,5 +12,5 @@ class Command(CheckCommand): def handle_noargs(self, **options): warnings.warn('"validate" has been deprecated in favor of "check".', - PendingDeprecationWarning) + RemovedInDjango19Warning) super(Command, self).handle_noargs(**options) diff --git a/django/core/management/sql.py b/django/core/management/sql.py index ccab11d2bd..c789701c47 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -10,6 +10,7 @@ from django.conf import settings from django.core.management.base import CommandError from django.db import models, router from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning def sql_create(app_config, style, connection): @@ -179,7 +180,7 @@ def custom_sql_for_model(model, style, connection): if os.path.exists(old_app_dir): warnings.warn("Custom SQL location '/models/sql' is " "deprecated, use '/sql' instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) app_dirs.append(old_app_dir) output = [] diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py index e5c295131e..ed0cfa3c34 100644 --- a/django/core/serializers/base.py +++ b/django/core/serializers/base.py @@ -5,6 +5,7 @@ import warnings from django.db import models from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning class SerializerDoesNotExist(KeyError): @@ -42,7 +43,7 @@ class Serializer(object): self.use_natural_keys = options.pop("use_natural_keys", False) if self.use_natural_keys: warnings.warn("``use_natural_keys`` is deprecated; use ``use_natural_foreign_keys`` instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) self.use_natural_foreign_keys = options.pop('use_natural_foreign_keys', False) or self.use_natural_keys self.use_natural_primary_keys = options.pop('use_natural_primary_keys', False) diff --git a/django/db/__init__.py b/django/db/__init__.py index e1af430dc2..928b652fcf 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -5,6 +5,7 @@ from django.db.utils import (DEFAULT_DB_ALIAS, DataError, OperationalError, IntegrityError, InternalError, ProgrammingError, NotSupportedError, DatabaseError, InterfaceError, Error, load_backend, ConnectionHandler, ConnectionRouter) +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.functional import cached_property @@ -61,7 +62,7 @@ class DefaultBackendProxy(object): @cached_property def _backend(self): warnings.warn("Accessing django.db.backend is deprecated.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) return load_backend(connections[DEFAULT_DB_ALIAS].settings_dict['ENGINE']) def __getattr__(self, item): @@ -79,7 +80,7 @@ backend = DefaultBackendProxy() def close_connection(**kwargs): warnings.warn( "close_connection is superseded by close_old_connections.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) # Avoid circular imports from django.db import transaction for conn in connections: diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 5c8bd0cef9..b274065a21 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -1402,7 +1402,7 @@ class BaseDatabaseValidation(object): # This is deliberately commented out. It exists as a marker to # remind us to remove this method, and the check_field() shim, # when the time comes. - # warnings.warn('"validate_field" has been deprecated", PendingDeprecationWarning) + # warnings.warn('"validate_field" has been deprecated", RemovedInDjango19Warning) pass def check_field(self, field, **kwargs): diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index 3ee1e8448e..a549c34f17 100644 --- a/django/db/backends/creation.py +++ b/django/db/backends/creation.py @@ -5,6 +5,7 @@ import warnings from django.conf import settings from django.db.utils import load_backend +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_bytes from django.utils.functional import cached_property from django.utils.six.moves import input @@ -474,7 +475,7 @@ class BaseDatabaseCreation(object): """ warnings.warn( "set_autocommit was moved from BaseDatabaseCreation to " - "BaseDatabaseWrapper.", DeprecationWarning, stacklevel=2) + "BaseDatabaseWrapper.", RemovedInDjango18Warning, stacklevel=2) return self.connection.set_autocommit(True) def sql_table_creation_suffix(self): diff --git a/django/db/backends/util.py b/django/db/backends/util.py index 957a0d5825..ef5e8acc15 100644 --- a/django/db/backends/util.py +++ b/django/db/backends/util.py @@ -1,7 +1,9 @@ import warnings +from django.utils.deprecation import RemovedInDjango19Warning + warnings.warn( "The django.db.backends.util module has been renamed. " - "Use django.db.backends.utils instead.", PendingDeprecationWarning) + "Use django.db.backends.utils instead.", RemovedInDjango19Warning) from django.db.backends.utils import * # NOQA diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index bdbdd5fd91..c054542e3e 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -19,6 +19,7 @@ from django.db.models.deletion import ( # NOQA CASCADE, PROTECT, SET, SET_NULL, SET_DEFAULT, DO_NOTHING, ProtectedError) from django.db.models.lookups import Lookup, Transform # NOQA from django.db.models import signals # NOQA +from django.utils.deprecation import RemovedInDjango19Warning def permalink(func): @@ -47,7 +48,7 @@ def make_alias(function_name): def alias(*args, **kwargs): warnings.warn( "django.db.models.%s is deprecated." % function_name, - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) # This raises a second warning. from . import loading return getattr(loading, function_name)(*args, **kwargs) diff --git a/django/db/models/base.py b/django/db/models/base.py index 81e8c2216e..ba89e6e037 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -22,12 +22,13 @@ from django.db.models.query_utils import DeferredAttribute, deferred_class_facto from django.db.models.deletion import Collector from django.db.models.options import Options from django.db.models import signals -from django.utils.translation import ugettext_lazy as _ -from django.utils.functional import curry -from django.utils.encoding import force_str, force_text from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning +from django.utils.encoding import force_str, force_text +from django.utils.functional import curry from django.utils.six.moves import zip from django.utils.text import get_text_list, capfirst +from django.utils.translation import ugettext_lazy as _ def subclass_exception(name, parents, module, attached_to=None): @@ -114,7 +115,7 @@ class ModelBase(type): msg += "Its app_label will be set to None in Django 1.9." else: msg += "This will no longer be supported in Django 1.9." - warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) + warnings.warn(msg, RemovedInDjango19Warning, stacklevel=2) model_module = sys.modules[new_class.__module__] package_components = model_module.__name__.split('.') diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 5e94e78c58..16a07002bc 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -19,6 +19,7 @@ from django import forms from django.core import exceptions, validators, checks from django.utils.datastructures import DictWrapper from django.utils.dateparse import parse_date, parse_datetime, parse_time +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.functional import curry, total_ordering, Promise from django.utils.text import capfirst from django.utils import timezone @@ -1618,7 +1619,7 @@ class IPAddressField(Field): def __init__(self, *args, **kwargs): warnings.warn("IPAddressField has been deprecated. Use GenericIPAddressField instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) kwargs['max_length'] = 15 super(IPAddressField, self).__init__(*args, **kwargs) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index e7b66217c5..e4c055ff63 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -14,7 +14,7 @@ from django.db.models.query import QuerySet from django.db.models.sql.datastructures import Col from django.utils.encoding import smart_text from django.utils import six -from django.utils.deprecation import RenameMethodsBase +from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.translation import ugettext_lazy as _ from django.utils.functional import curry, cached_property from django.core import exceptions @@ -346,8 +346,8 @@ class RelatedField(Field): class RenameRelatedObjectDescriptorMethods(RenameMethodsBase): renamed_methods = ( - ('get_query_set', 'get_queryset', DeprecationWarning), - ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning), + ('get_query_set', 'get_queryset', RemovedInDjango18Warning), + ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning), ) diff --git a/django/db/models/loading.py b/django/db/models/loading.py index 31a3690f95..82cb2dc4da 100644 --- a/django/db/models/loading.py +++ b/django/db/models/loading.py @@ -1,11 +1,13 @@ import warnings from django.apps import apps +from django.utils.deprecation import RemovedInDjango19Warning + warnings.warn( "The utilities in django.db.models.loading are deprecated " "in favor of the new application loading system.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) __all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models', 'load_app', 'app_cache_ready') diff --git a/django/db/models/manager.py b/django/db/models/manager.py index f014edcd76..4f28253de9 100644 --- a/django/db/models/manager.py +++ b/django/db/models/manager.py @@ -6,7 +6,7 @@ from django.db.models.query import QuerySet from django.db.models import signals from django.db.models.fields import FieldDoesNotExist from django.utils import six -from django.utils.deprecation import RenameMethodsBase +from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.encoding import python_2_unicode_compatible @@ -54,8 +54,8 @@ signals.class_prepared.connect(ensure_default_manager) class RenameManagerMethods(RenameMethodsBase): renamed_methods = ( - ('get_query_set', 'get_queryset', DeprecationWarning), - ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning), + ('get_query_set', 'get_queryset', RemovedInDjango18Warning), + ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning), ) diff --git a/django/db/models/options.py b/django/db/models/options.py index 4eec2df17c..d204bcf84c 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -10,8 +10,9 @@ from django.db.models.fields.related import ManyToManyRel from django.db.models.fields import AutoField, FieldDoesNotExist from django.db.models.fields.proxy import OrderWrt from django.utils import six -from django.utils.functional import cached_property +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_text, smart_text, python_2_unicode_compatible +from django.utils.functional import cached_property from django.utils.text import camel_case_to_spaces from django.utils.translation import activate, deactivate_all, get_language, string_concat @@ -171,7 +172,7 @@ class Options(object): """ warnings.warn( "Options.module_name has been deprecated in favor of model_name", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) return self.model_name def _prepare(self, model): @@ -462,7 +463,7 @@ class Options(object): warnings.warn( "`Options.get_add_permission` has been deprecated in favor " "of `django.contrib.auth.get_permission_codename`.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) return 'add_%s' % self.model_name def get_change_permission(self): @@ -473,7 +474,7 @@ class Options(object): warnings.warn( "`Options.get_change_permission` has been deprecated in favor " "of `django.contrib.auth.get_permission_codename`.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) return 'change_%s' % self.model_name def get_delete_permission(self): @@ -484,7 +485,7 @@ class Options(object): warnings.warn( "`Options.get_delete_permission` has been deprecated in favor " "of `django.contrib.auth.get_permission_codename`.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) return 'delete_%s' % self.model_name def get_all_related_objects(self, local_only=False, include_hidden=False, diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 25ebe5598e..5b27c885d7 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -11,9 +11,7 @@ from collections import OrderedDict import copy import warnings -from django.utils.encoding import force_text -from django.utils.tree import Node -from django.utils import six +from django.core.exceptions import FieldError from django.db import connections, DEFAULT_DB_ALIAS from django.db.models.constants import LOOKUP_SEP from django.db.models.aggregates import refs_aggregate @@ -29,7 +27,10 @@ from django.db.models.sql.datastructures import EmptyResultSet, Empty, MultiJoin from django.db.models.sql.expressions import SQLEvaluator from django.db.models.sql.where import (WhereNode, Constraint, EverythingNode, ExtraWhere, AND, OR, EmptyWhere) -from django.core.exceptions import FieldError +from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning +from django.utils.encoding import force_text +from django.utils.tree import Node __all__ = ['Query', 'RawQuery'] @@ -1043,7 +1044,7 @@ class Query(object): elif callable(value): warnings.warn( "Passing callable arguments to queryset is deprecated.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) value = value() elif isinstance(value, ExpressionNode): # If value is a query expression, evaluate it diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index be0c559c1b..2b315be7c8 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -11,6 +11,7 @@ from django.conf import settings from django.db.models.fields import DateTimeField, Field from django.db.models.sql.datastructures import EmptyResultSet, Empty from django.db.models.sql.aggregates import Aggregate +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.six.moves import xrange from django.utils import timezone from django.utils import tree @@ -177,7 +178,7 @@ class WhereNode(tree.Node): """ warnings.warn( "The make_atom() method will be removed in Django 1.9. Use Lookup class instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) lvalue, lookup_type, value_annotation, params_or_value = child field_internal_type = lvalue.field.get_internal_type() if lvalue.field else None @@ -355,7 +356,7 @@ class Constraint(object): def __init__(self, alias, col, field): warnings.warn( "The Constraint class will be removed in Django 1.9. Use Lookup class instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) self.alias, self.col, self.field = alias, col, field def prepare(self, lookup_type, value): diff --git a/django/db/transaction.py b/django/db/transaction.py index 25ec81d87a..61cb39791e 100644 --- a/django/db/transaction.py +++ b/django/db/transaction.py @@ -20,6 +20,7 @@ from django.db import ( connections, DEFAULT_DB_ALIAS, DatabaseError, ProgrammingError) from django.utils.decorators import available_attrs +from django.utils.deprecation import RemovedInDjango18Warning class TransactionManagementError(ProgrammingError): @@ -110,22 +111,22 @@ def set_clean(using=None): def is_managed(using=None): warnings.warn("'is_managed' is deprecated.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) def managed(flag=True, using=None): warnings.warn("'managed' no longer serves a purpose.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) def commit_unless_managed(using=None): warnings.warn("'commit_unless_managed' is now a no-op.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) def rollback_unless_managed(using=None): warnings.warn("'rollback_unless_managed' is now a no-op.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) ############### @@ -450,7 +451,7 @@ def autocommit(using=None): your settings file and want the default behavior in some view functions. """ warnings.warn("autocommit is deprecated in favor of set_autocommit.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) def entering(using): enter_transaction_management(managed=False, using=using) @@ -469,7 +470,7 @@ def commit_on_success(using=None): control in Web apps. """ warnings.warn("commit_on_success is deprecated in favor of atomic.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) def entering(using): enter_transaction_management(using=using) @@ -500,7 +501,7 @@ def commit_manually(using=None): themselves. """ warnings.warn("commit_manually is deprecated in favor of set_autocommit.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) def entering(using): enter_transaction_management(using=using) diff --git a/django/db/utils.py b/django/db/utils.py index b7303351d9..f0811f1b05 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -6,6 +6,7 @@ import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured +from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning from django.utils.functional import cached_property from django.utils.module_loading import import_string from django.utils._os import upath @@ -169,7 +170,7 @@ class ConnectionHandler(object): if settings.TRANSACTIONS_MANAGED: warnings.warn( "TRANSACTIONS_MANAGED is deprecated. Use AUTOCOMMIT instead.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) conn.setdefault('AUTOCOMMIT', False) conn.setdefault('AUTOCOMMIT', True) conn.setdefault('ENGINE', 'django.db.backends.dummy') @@ -272,7 +273,7 @@ class ConnectionRouter(object): warnings.warn( 'Router.allow_syncdb has been deprecated and will stop working in Django 1.9. ' 'Rename the method to allow_migrate.', - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) except AttributeError: # If the router doesn't have a method, skip to the next one. pass diff --git a/django/forms/fields.py b/django/forms/fields.py index 1866bc1786..b9a3d4d6c5 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -25,6 +25,7 @@ from django.forms.widgets import ( from django.utils import formats from django.utils.encoding import smart_text, force_str, force_text from django.utils.ipv6 import clean_ipv6_address +from django.utils.deprecation import RemovedInDjango19Warning from django.utils import six from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit from django.utils.translation import ugettext_lazy as _, ungettext_lazy @@ -502,7 +503,7 @@ class DateTimeField(BaseTemporalField): warnings.warn( 'Using SplitDateTimeWidget with DateTimeField is deprecated. ' 'Use SplitDateTimeField instead.', - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) if len(value) != 2: raise ValidationError(self.error_messages['invalid'], code='invalid') if value[0] in self.empty_values and value[1] in self.empty_values: @@ -1169,7 +1170,7 @@ class IPAddressField(CharField): def __init__(self, *args, **kwargs): warnings.warn("IPAddressField has been deprecated. Use GenericIPAddressField instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) super(IPAddressField, self).__init__(*args, **kwargs) def to_python(self, value): diff --git a/django/forms/forms.py b/django/forms/forms.py index 26967fba5c..19164aacae 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -12,8 +12,9 @@ from django.core.exceptions import ValidationError, NON_FIELD_ERRORS from django.forms.fields import Field, FileField from django.forms.utils import flatatt, ErrorDict, ErrorList from django.forms.widgets import Media, MediaDefiningClass, TextInput, Textarea -from django.utils.html import conditional_escape, format_html +from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning from django.utils.encoding import smart_text, force_text, python_2_unicode_compatible +from django.utils.html import conditional_escape, format_html from django.utils.safestring import mark_safe from django.utils.translation import ugettext as _ from django.utils import six @@ -43,7 +44,7 @@ def get_declared_fields(bases, attrs, with_base_fields=True): warnings.warn( "get_declared_fields is deprecated and will be removed in Django 1.9.", - PendingDeprecationWarning, + RemovedInDjango19Warning, stacklevel=2, ) @@ -431,7 +432,7 @@ class BaseForm(object): if hasattr(field.widget, '_has_changed'): warnings.warn("The _has_changed method on widgets is deprecated," " define it at field level instead.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) if field.widget._has_changed(initial_value, data_value): self._changed_data.append(name) elif field._has_changed(initial_value, data_value): diff --git a/django/forms/models.py b/django/forms/models.py index a0b47e64b4..6a3dc62342 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -8,15 +8,17 @@ from __future__ import unicode_literals from collections import OrderedDict import warnings -from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, FieldError +from django.core.exceptions import ( + ValidationError, NON_FIELD_ERRORS, FieldError) from django.forms.fields import Field, ChoiceField from django.forms.forms import DeclarativeFieldsMetaclass, BaseForm from django.forms.formsets import BaseFormSet, formset_factory from django.forms.utils import ErrorList from django.forms.widgets import (SelectMultiple, HiddenInput, MultipleHiddenInput, CheckboxSelectMultiple) -from django.utils.encoding import smart_text, force_text from django.utils import six +from django.utils.deprecation import RemovedInDjango18Warning +from django.utils.encoding import smart_text, force_text from django.utils.text import get_text_list, capfirst from django.utils.translation import ugettext_lazy as _, ugettext, string_concat @@ -269,7 +271,7 @@ class ModelFormMetaclass(DeclarativeFieldsMetaclass): warnings.warn("Creating a ModelForm without either the 'fields' attribute " "or the 'exclude' attribute is deprecated - form %s " "needs updating" % name, - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) if opts.fields == ALL_FIELDS: # Sentinel for fields_for_model to indicate "get the list of @@ -533,7 +535,7 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None, getattr(Meta, 'exclude', None) is None): warnings.warn("Calling modelform_factory without defining 'fields' or " "'exclude' explicitly is deprecated", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) # Instatiate type(form) in order to use the same metaclass as form. return type(form)(class_name, (form,), form_class_attrs) @@ -825,7 +827,7 @@ def modelformset_factory(model, form=ModelForm, formfield_callback=None, getattr(meta, 'exclude', exclude) is None): warnings.warn("Calling modelformset_factory without defining 'fields' or " "'exclude' explicitly is deprecated", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) form = modelform_factory(model, form=form, fields=fields, exclude=exclude, formfield_callback=formfield_callback, diff --git a/django/forms/util.py b/django/forms/util.py index e3638a0c06..42d521105e 100644 --- a/django/forms/util.py +++ b/django/forms/util.py @@ -1,7 +1,9 @@ import warnings +from django.utils.deprecation import RemovedInDjango19Warning + warnings.warn( "The django.forms.util module has been renamed. " - "Use django.forms.utils instead.", PendingDeprecationWarning) + "Use django.forms.utils instead.", RemovedInDjango19Warning) from django.forms.utils import * # NOQA diff --git a/django/forms/utils.py b/django/forms/utils.py index d31bd81ffe..2147014a5d 100644 --- a/django/forms/utils.py +++ b/django/forms/utils.py @@ -10,8 +10,9 @@ except ImportError: # Python 2 from UserList import UserList from django.conf import settings -from django.utils.html import format_html, format_html_join, escape +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.html import format_html, format_html_join, escape from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from django.utils import six @@ -40,7 +41,7 @@ def flatatt(attrs): 'action': "be rendered as '%s'" % attr_name if value else "not be rendered", 'bool_value': value, }, - DeprecationWarning + RemovedInDjango18Warning ) return format_html_join('', ' {0}="{1}"', sorted(attrs.items())) diff --git a/django/forms/widgets.py b/django/forms/widgets.py index a9754bbc4e..53003749d3 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -11,9 +11,10 @@ import warnings from django.conf import settings from django.forms.utils import flatatt, to_current_timezone from django.utils.datastructures import MultiValueDict, MergeDict +from django.utils.deprecation import RemovedInDjango18Warning +from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.html import conditional_escape, format_html from django.utils.translation import ugettext_lazy -from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.safestring import mark_safe from django.utils import formats, six from django.utils.six.moves.urllib.parse import urljoin @@ -191,7 +192,7 @@ class Widget(six.with_metaclass(MediaDefiningClass)): warnings.warn( "`is_hidden` property is now read-only (and checks `input_type`). " "Please update your code.", - DeprecationWarning, stacklevel=2 + RemovedInDjango18Warning, stacklevel=2 ) def subwidgets(self, name, value, attrs=None, choices=()): @@ -636,7 +637,7 @@ class RadioChoiceInput(ChoiceInput): class RadioInput(RadioChoiceInput): def __init__(self, *args, **kwargs): msg = "RadioInput has been deprecated. Use RadioChoiceInput instead." - warnings.warn(msg, DeprecationWarning, stacklevel=2) + warnings.warn(msg, RemovedInDjango18Warning, stacklevel=2) super(RadioInput, self).__init__(*args, **kwargs) diff --git a/django/middleware/cache.py b/django/middleware/cache.py index a99d428ad9..a58b21f58a 100644 --- a/django/middleware/cache.py +++ b/django/middleware/cache.py @@ -48,6 +48,7 @@ import warnings from django.conf import settings from django.core.cache import caches, DEFAULT_CACHE_ALIAS from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers, get_max_age +from django.utils.deprecation import RemovedInDjango18Warning class UpdateCacheMiddleware(object): @@ -194,6 +195,6 @@ class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware): if self.cache_anonymous_only: msg = "CACHE_MIDDLEWARE_ANONYMOUS_ONLY has been deprecated and will be removed in Django 1.8." - warnings.warn(msg, DeprecationWarning, stacklevel=1) + warnings.warn(msg, RemovedInDjango18Warning, stacklevel=1) self.cache = caches[self.cache_alias] diff --git a/django/middleware/common.py b/django/middleware/common.py index 6ff8a8d6e7..ce17a02c9c 100644 --- a/django/middleware/common.py +++ b/django/middleware/common.py @@ -7,6 +7,7 @@ from django.conf import settings from django.core.mail import mail_managers from django.core import urlresolvers from django import http +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_text from django.utils.http import urlquote from django.utils import six @@ -110,7 +111,7 @@ class CommonMiddleware(object): if settings.SEND_BROKEN_LINK_EMAILS: warnings.warn("SEND_BROKEN_LINK_EMAILS is deprecated. " "Use BrokenLinkEmailsMiddleware instead.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) BrokenLinkEmailsMiddleware().process_response(request, response) if settings.USE_ETAGS: diff --git a/django/middleware/doc.py b/django/middleware/doc.py index 2034880eca..9d942457b4 100644 --- a/django/middleware/doc.py +++ b/django/middleware/doc.py @@ -1,6 +1,9 @@ """XViewMiddleware has been moved to django.contrib.admindocs.middleware.""" import warnings -warnings.warn(__doc__, DeprecationWarning, stacklevel=2) + +from django.utils.deprecation import RemovedInDjango18Warning + +warnings.warn(__doc__, RemovedInDjango18Warning, stacklevel=2) from django.contrib.admindocs.middleware import XViewMiddleware # NOQA diff --git a/django/middleware/transaction.py b/django/middleware/transaction.py index 677d1fc504..a95c4a89c2 100644 --- a/django/middleware/transaction.py +++ b/django/middleware/transaction.py @@ -2,6 +2,7 @@ import warnings from django.core.exceptions import MiddlewareNotUsed from django.db import connection, transaction +from django.utils.deprecation import RemovedInDjango18Warning class TransactionMiddleware(object): @@ -15,7 +16,7 @@ class TransactionMiddleware(object): def __init__(self): warnings.warn( "TransactionMiddleware is deprecated in favor of ATOMIC_REQUESTS.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) if connection.settings_dict['ATOMIC_REQUESTS']: raise MiddlewareNotUsed diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 4f89c930b3..c61851bbd1 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -17,6 +17,7 @@ from django.template.base import (Node, NodeList, Template, Context, Library, render_value_in_context) from django.template.smartif import IfParser, Literal from django.template.defaultfilters import date +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_text, smart_text from django.utils.safestring import mark_safe from django.utils.html import format_html @@ -591,7 +592,7 @@ def cycle(parser, token, escape=False): "'The `cycle` template tag is changing to escape its arguments; " "the non-autoescaping version is deprecated. Load it " "from the `future` tag library to start using the new behavior.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) # Note: This returns the exact same node on each {% cycle name %} call; # that is, the node object returned from {% cycle a b c as name %} and the @@ -739,7 +740,7 @@ def firstof(parser, token, escape=False): "'The `firstof` template tag is changing to escape its arguments; " "the non-autoescaping version is deprecated. Load it " "from the `future` tag library to start using the new behavior.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) bits = token.split_contents()[1:] if len(bits) < 1: diff --git a/django/templatetags/future.py b/django/templatetags/future.py index c8127ac102..f10d0854bf 100644 --- a/django/templatetags/future.py +++ b/django/templatetags/future.py @@ -2,6 +2,7 @@ import warnings from django.template import Library from django.template import defaulttags +from django.utils.deprecation import RemovedInDjango19Warning register = Library() @@ -11,7 +12,7 @@ def ssi(parser, token): warnings.warn( "Loading the `ssi` tag from the `future` library is deprecated and " "will be removed in Django 1.9. Use the default `ssi` tag instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) return defaulttags.ssi(parser, token) @@ -20,7 +21,7 @@ def url(parser, token): warnings.warn( "Loading the `url` tag from the `future` library is deprecated and " "will be removed in Django 1.9. Use the default `url` tag instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) return defaulttags.url(parser, token) diff --git a/django/test/_doctest.py b/django/test/_doctest.py index 4d9346b71f..acf19c7d66 100644 --- a/django/test/_doctest.py +++ b/django/test/_doctest.py @@ -51,10 +51,12 @@ details. """ import warnings +from django.utils.deprecation import RemovedInDjango18Warning + warnings.warn( "The django.test._doctest module is deprecated; " "use the doctest module from the Python standard library instead.", - DeprecationWarning) + RemovedInDjango18Warning) __docformat__ = 'reStructuredText en' @@ -2085,7 +2087,7 @@ class Tester: warnings.warn("class Tester is deprecated; " "use class doctest.DocTestRunner instead", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) if mod is None and globs is None: raise TypeError("Tester.__init__: must specify mod or globs") if mod is not None and not inspect.ismodule(mod): diff --git a/django/test/simple.py b/django/test/simple.py index 5f33044de6..956294db82 100644 --- a/django/test/simple.py +++ b/django/test/simple.py @@ -16,6 +16,7 @@ from django.test.utils import compare_xml, strip_quotes # django.utils.unittest is deprecated, but so is django.test.simple, # and the latter will be removed before the former. from django.utils import unittest +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.module_loading import module_has_submodule __all__ = ('DjangoTestSuiteRunner',) @@ -23,7 +24,7 @@ __all__ = ('DjangoTestSuiteRunner',) warnings.warn( "The django.test.simple module and DjangoTestSuiteRunner are deprecated; " "use django.test.runner.DiscoverRunner instead.", - DeprecationWarning) + RemovedInDjango18Warning) # The module name for tests outside models.py TEST_MODULE = 'tests' diff --git a/django/test/utils.py b/django/test/utils.py index 03e8f17ad1..c8d9aa1dba 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -17,8 +17,9 @@ from django.http import request from django.template import Template, loader, TemplateDoesNotExist from django.template.loaders import cached from django.test.signals import template_rendered, setting_changed -from django.utils.encoding import force_str from django.utils import six +from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning +from django.utils.encoding import force_str from django.utils.translation import deactivate @@ -457,8 +458,7 @@ class CaptureQueriesContext(object): class IgnoreDeprecationWarningsMixin(object): - - warning_classes = [DeprecationWarning] + warning_classes = [RemovedInDjango18Warning] def setUp(self): super(IgnoreDeprecationWarningsMixin, self).setUp() @@ -473,13 +473,11 @@ class IgnoreDeprecationWarningsMixin(object): class IgnorePendingDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin): - - warning_classes = [PendingDeprecationWarning] + warning_classes = [RemovedInDjango19Warning] class IgnoreAllDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin): - - warning_classes = [PendingDeprecationWarning, DeprecationWarning] + warning_classes = [RemovedInDjango19Warning, RemovedInDjango18Warning] @contextmanager diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 49855dd33b..2efcd00eb0 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -1,7 +1,9 @@ import copy import warnings from collections import OrderedDict + from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning class MergeDict(object): @@ -14,7 +16,7 @@ class MergeDict(object): """ def __init__(self, *dicts): warnings.warn('`MergeDict` is deprecated, use `dict.update()` ' - 'instead.', PendingDeprecationWarning, 2) + 'instead.', RemovedInDjango19Warning, 2) self.dicts = dicts def __bool__(self): @@ -131,7 +133,7 @@ class SortedDict(dict): def __init__(self, data=None): warnings.warn( "SortedDict is deprecated and will be removed in Django 1.9.", - PendingDeprecationWarning, stacklevel=2 + RemovedInDjango19Warning, stacklevel=2 ) if data is None or isinstance(data, dict): data = data or [] diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py index edbb5ca5ea..a4f928e73b 100644 --- a/django/utils/deprecation.py +++ b/django/utils/deprecation.py @@ -2,6 +2,14 @@ import inspect import warnings +class RemovedInDjango19Warning(PendingDeprecationWarning): + pass + + +class RemovedInDjango18Warning(DeprecationWarning): + pass + + class warn_about_renamed_method(object): def __init__(self, class_name, old_method_name, new_method_name, deprecation_warning): self.class_name = class_name diff --git a/django/utils/dictconfig.py b/django/utils/dictconfig.py index e79dc041ef..e2c7a43c44 100644 --- a/django/utils/dictconfig.py +++ b/django/utils/dictconfig.py @@ -1,7 +1,9 @@ import warnings +from django.utils.deprecation import RemovedInDjango19Warning + warnings.warn("django.utils.dictconfig will be removed in Django 1.9.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) # This is a copy of the Python logging.config.dictconfig module, # reproduced with permission. It is provided here for backwards diff --git a/django/utils/functional.py b/django/utils/functional.py index e5c49ccddd..9668bc682b 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -5,6 +5,7 @@ import sys import warnings from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.six.moves import copyreg @@ -27,7 +28,7 @@ def memoize(func, cache, num_args): """ warnings.warn("memoize wrapper is deprecated and will be removed in " "Django 1.9. Use django.utils.lru_cache instead.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) @wraps(func) def wrapper(*args): diff --git a/django/utils/html.py b/django/utils/html.py index aab87df9f7..6afd6b62fa 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -5,9 +5,10 @@ from __future__ import unicode_literals import re import warnings -from django.utils.safestring import SafeData, mark_safe +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_text, force_str from django.utils.functional import allow_lazy +from django.utils.safestring import SafeData, mark_safe from django.utils import six from django.utils.six.moves.urllib.parse import quote, unquote, urlsplit, urlunsplit from django.utils.text import normalize_newlines @@ -177,7 +178,7 @@ def fix_ampersands(value): """Returns the given HTML with all unencoded ampersands encoded correctly.""" # As fix_ampersands is wrapped in allow_lazy, stacklevel 3 is more useful than 2. warnings.warn("The fix_ampersands function is deprecated and will be removed in Django 1.8.", - DeprecationWarning, stacklevel=3) + RemovedInDjango18Warning, stacklevel=3) return unencoded_ampersands_re.sub('&', force_text(value)) fix_ampersands = allow_lazy(fix_ampersands, six.text_type) @@ -296,7 +297,7 @@ def clean_html(text): """ # As clean_html is wrapped in allow_lazy, stacklevel 3 is more useful than 2. warnings.warn("The clean_html function is deprecated and will be removed in Django 1.8.", - DeprecationWarning, stacklevel=3) + RemovedInDjango18Warning, stacklevel=3) text = normalize_newlines(text) text = re.sub(r'<(/?)\s*b\s*>', '<\\1strong>', text) text = re.sub(r'<(/?)\s*i\s*>', '<\\1em>', text) diff --git a/django/utils/image.py b/django/utils/image.py index ff5dcc57e5..795300c1e4 100644 --- a/django/utils/image.py +++ b/django/utils/image.py @@ -75,6 +75,7 @@ from __future__ import unicode_literals import warnings from django.core.exceptions import ImproperlyConfigured +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.translation import ugettext_lazy as _ @@ -147,7 +148,7 @@ def _detect_image_library(): warnings.warn( "Support for the PIL will be removed in Django 1.8. Please " + "uninstall it & install Pillow instead.", - DeprecationWarning + RemovedInDjango18Warning ) return PILImage, PIL_imaging, PILImageFile diff --git a/django/utils/importlib.py b/django/utils/importlib.py index 8059f16095..f05638e2e8 100644 --- a/django/utils/importlib.py +++ b/django/utils/importlib.py @@ -3,9 +3,11 @@ import warnings import sys from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning + warnings.warn("django.utils.importlib will be removed in Django 1.9.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) def _resolve_name(name, package, level): diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py index 7ba0381307..bd546ac405 100644 --- a/django/utils/module_loading.py +++ b/django/utils/module_loading.py @@ -9,6 +9,7 @@ import warnings from django.core.exceptions import ImproperlyConfigured from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning def import_string(dotted_path): @@ -39,7 +40,7 @@ def import_by_path(dotted_path, error_prefix=''): """ warnings.warn( 'import_by_path() has been deprecated. Use import_string() instead.', - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) try: attr = import_string(dotted_path) except ImportError as e: diff --git a/django/utils/text.py b/django/utils/text.py index 1eee68bb17..df6e1d0c46 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -6,6 +6,7 @@ from gzip import GzipFile from io import BytesIO import warnings +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_text from django.utils.functional import allow_lazy, SimpleLazyObject from django.utils import six @@ -332,7 +333,7 @@ def javascript_quote(s, quote_double_quotes=False): "django.utils.text.javascript_quote() is deprecated. " "Use django.utils.html.escapejs() instead." ) - warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) + warnings.warn(msg, RemovedInDjango19Warning, stacklevel=2) def fix(match): return "\\u%04x" % ord(match.group(1)) diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 80f18d6c6b..a22cd62b9b 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -12,6 +12,7 @@ import warnings from django.apps import apps from django.dispatch import receiver from django.test.signals import setting_changed +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_str, force_text from django.utils._os import upath from django.utils.safestring import mark_safe, SafeData @@ -213,7 +214,7 @@ def activate(language): msg = ("The use of the language code '%s' is deprecated. " "Please use the '%s' translation instead.") warnings.warn(msg % (language, _DJANGO_DEPRECATED_LOCALES[language]), - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) _active.value = translation(language) diff --git a/django/utils/tzinfo.py b/django/utils/tzinfo.py index 8d996567fe..973a27a313 100644 --- a/django/utils/tzinfo.py +++ b/django/utils/tzinfo.py @@ -6,12 +6,13 @@ from datetime import timedelta, tzinfo import time import warnings +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_str, force_text, DEFAULT_LOCALE_ENCODING warnings.warn( "django.utils.tzinfo will be removed in Django 1.9. " "Use django.utils.timezone instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) # Python's doc say: "A tzinfo subclass must have an __init__() method that can @@ -25,7 +26,7 @@ class FixedOffset(tzinfo): warnings.warn( "django.utils.tzinfo.FixedOffset will be removed in Django 1.9. " "Use django.utils.timezone.get_fixed_timezone instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) if isinstance(offset, timedelta): self.__offset = offset offset = self.__offset.seconds // 60 @@ -63,7 +64,7 @@ class LocalTimezone(tzinfo): warnings.warn( "django.utils.tzinfo.LocalTimezone will be removed in Django 1.9. " "Use django.utils.timezone.get_default_timezone instead.", - PendingDeprecationWarning) + RemovedInDjango19Warning) tzinfo.__init__(self) self.__dt = dt self._tzname = self.tzname(dt) diff --git a/django/utils/unittest.py b/django/utils/unittest.py index b9aa1bbd73..8d337259ba 100644 --- a/django/utils/unittest.py +++ b/django/utils/unittest.py @@ -2,8 +2,10 @@ from __future__ import absolute_import import warnings +from django.utils.deprecation import RemovedInDjango19Warning + warnings.warn("django.utils.unittest will be removed in Django 1.9.", - PendingDeprecationWarning, stacklevel=2) + RemovedInDjango19Warning, stacklevel=2) try: from unittest2 import * diff --git a/django/views/defaults.py b/django/views/defaults.py index 2f54fcd263..77e09185eb 100644 --- a/django/views/defaults.py +++ b/django/views/defaults.py @@ -3,6 +3,7 @@ import warnings from django import http from django.template import (Context, RequestContext, loader, Template, TemplateDoesNotExist) +from django.utils.deprecation import RemovedInDjango18Warning from django.views.decorators.csrf import requires_csrf_token @@ -86,6 +87,6 @@ def shortcut(request, content_type_id, object_id): warnings.warn( "django.views.defaults.shortcut will be removed in Django 1.8. " "Import it from django.contrib.contenttypes.views instead.", - DeprecationWarning, stacklevel=2) + RemovedInDjango18Warning, stacklevel=2) from django.contrib.contenttypes.views import shortcut as real_shortcut return real_shortcut(request, content_type_id, object_id) diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py index 84d9eb2fee..d581279f28 100644 --- a/django/views/generic/edit.py +++ b/django/views/generic/edit.py @@ -1,8 +1,9 @@ import warnings -from django.forms import models as model_forms from django.core.exceptions import ImproperlyConfigured +from django.forms import models as model_forms from django.http import HttpResponseRedirect +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_text from django.views.generic.base import TemplateResponseMixin, ContextMixin, View from django.views.generic.detail import (SingleObjectMixin, @@ -113,7 +114,7 @@ class ModelFormMixin(FormMixin, SingleObjectMixin): if self.fields is None: warnings.warn("Using ModelFormMixin (base class of %s) without " "the 'fields' attribute is deprecated." % self.__class__.__name__, - DeprecationWarning) + RemovedInDjango18Warning) return model_forms.modelform_factory(model, fields=self.fields) diff --git a/docs/internals/contributing/writing-code/submitting-patches.txt b/docs/internals/contributing/writing-code/submitting-patches.txt index 37354f7a81..4efeab9fc5 100644 --- a/docs/internals/contributing/writing-code/submitting-patches.txt +++ b/docs/internals/contributing/writing-code/submitting-patches.txt @@ -173,11 +173,12 @@ There are a couple reasons that code in Django might be deprecated: As the :ref:`deprecation policy` describes, the first release of Django that deprecates a feature (``A.B``) should raise a -``PendingDeprecationWarning`` when the deprecated feature is invoked. Assuming +``RemovedInDjangoXXWarning`` (where XX is the Django version where the feature +will be removed) when the deprecated feature is invoked. Assuming we have a good test coverage, these warnings will be shown by the test suite when :ref:`running it ` with warnings enabled: ``python -Wall runtests.py``. This is annoying and the output of the test suite -should remain clean. Thus, when adding a ``PendingDeprecationWarning`` you need +should remain clean. Thus, when adding a ``RemovedInDjangoXXWarning`` you need to eliminate or silence any warnings generated when running the tests. The first step is to remove any use of the deprecated behavior by Django itself. @@ -218,9 +219,8 @@ Finally, there are a couple of updates to Django's documentation to make: under the ``A.B+2`` version describing what code will be removed. Once you have completed these steps, you are finished with the deprecation. -In each minor release, all ``PendingDeprecationWarning``\s are promoted to -``DeprecationWarning``\s and any features marked with ``DeprecationWarning`` -are removed. +In each minor release, all ``RemovedInDjangoXXWarning``\s matching the new +version are removed. Javascript patches ------------------ diff --git a/docs/internals/release-process.txt b/docs/internals/release-process.txt index d06dbac954..43d23717fc 100644 --- a/docs/internals/release-process.txt +++ b/docs/internals/release-process.txt @@ -58,18 +58,17 @@ security purposes, please see :doc:`our security policies `. ``A.B+2``. So, for example, if we decided to start the deprecation of a function in - Django 1.5: + Django 1.7: - * Django 1.5 will contain a backwards-compatible replica of the function which - will raise a ``PendingDeprecationWarning``. This warning is silent by + * Django 1.7 will contain a backwards-compatible replica of the function which + will raise a ``RemovedInDjango19Warning``. This warning is silent by default; you can turn on display of these warnings with the ``-Wd`` option of Python. - * Django 1.6 will contain the backwards-compatible replica, but the warning - will be promoted to a full-fledged ``DeprecationWarning``. This warning is - *loud* by default, and will likely be quite annoying. + * Django 1.8 will still contain the backwards-compatible replica. This + warning becomes *loud* by default, and will likely be quite annoying. - * Django 1.7 will remove the feature outright. + * Django 1.9 will remove the feature outright. Micro release Micro releases (1.5.1, 1.6.2, 1.6.1, etc.) will be issued as needed, often to diff --git a/tests/defaultfilters/tests.py b/tests/defaultfilters/tests.py index 47381b7db7..ee328f4e38 100644 --- a/tests/defaultfilters/tests.py +++ b/tests/defaultfilters/tests.py @@ -20,8 +20,9 @@ from django.template.defaultfilters import ( from django.test import TestCase from django.utils import six from django.utils import translation -from django.utils.safestring import SafeData +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import python_2_unicode_compatible +from django.utils.safestring import SafeData class DefaultFiltersTests(TestCase): @@ -126,7 +127,7 @@ class DefaultFiltersTests(TestCase): def test_fix_ampersands(self): with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInDjango18Warning) self.assertEqual(fix_ampersands_filter('Jack & Jill & Jeroboam'), 'Jack & Jill & Jeroboam') diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py index 2a0922a0a8..717f32344c 100644 --- a/tests/deprecation/tests.py +++ b/tests/deprecation/tests.py @@ -1,4 +1,5 @@ from __future__ import unicode_literals + import warnings from django.test import SimpleTestCase, RequestFactory, override_settings diff --git a/tests/forms_tests/tests/test_widgets.py b/tests/forms_tests/tests/test_widgets.py index 96a9f0dcb1..8f21523a98 100644 --- a/tests/forms_tests/tests/test_widgets.py +++ b/tests/forms_tests/tests/test_widgets.py @@ -16,6 +16,7 @@ from django.forms import ( Textarea, TextInput, TimeInput, ) from django.forms.widgets import RadioFieldRenderer +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.safestring import mark_safe from django.utils import six from django.utils.translation import activate, deactivate, override @@ -1094,7 +1095,7 @@ class WidgetTests(TestCase): field = DateTimeField(widget=SplitDateTimeWidget, required=False) with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=PendingDeprecationWarning) + warnings.filterwarnings("ignore", category=RemovedInDjango19Warning) form = SplitDateForm({'field': ''}) self.assertTrue(form.is_valid()) form = SplitDateForm({'field': ['', '']}) @@ -1104,7 +1105,7 @@ class WidgetTests(TestCase): field = DateTimeField(widget=SplitDateTimeWidget, required=True) with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=PendingDeprecationWarning) + warnings.filterwarnings("ignore", category=RemovedInDjango19Warning) form = SplitDateRequiredForm({'field': ''}) self.assertFalse(form.is_valid()) form = SplitDateRequiredForm({'field': ['', '']}) diff --git a/tests/generic_views/test_edit.py b/tests/generic_views/test_edit.py index 92732c4f5f..d7982685c0 100644 --- a/tests/generic_views/test_edit.py +++ b/tests/generic_views/test_edit.py @@ -8,6 +8,7 @@ from django.core.urlresolvers import reverse from django import forms from django.test import TestCase from django.test.client import RequestFactory +from django.utils.deprecation import RemovedInDjango18Warning from django.views.generic.base import View from django.views.generic.edit import FormMixin, ModelFormMixin, CreateView @@ -152,7 +153,7 @@ class CreateViewTests(TestCase): def test_create_view_all_fields(self): with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always", DeprecationWarning) + warnings.simplefilter("always", RemovedInDjango18Warning) class MyCreateView(CreateView): model = Author @@ -165,7 +166,7 @@ class CreateViewTests(TestCase): def test_create_view_without_explicit_fields(self): with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always", DeprecationWarning) + warnings.simplefilter("always", RemovedInDjango18Warning) class MyCreateView(CreateView): model = Author @@ -176,7 +177,7 @@ class CreateViewTests(TestCase): ['name', 'slug']) # but with a warning: - self.assertEqual(w[0].category, DeprecationWarning) + self.assertEqual(w[0].category, RemovedInDjango18Warning) class UpdateViewTests(TestCase): diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py index 20b95d101b..9dcc054a64 100644 --- a/tests/httpwrappers/tests.py +++ b/tests/httpwrappers/tests.py @@ -18,6 +18,7 @@ from django.http import (QueryDict, HttpResponse, HttpResponseRedirect, SimpleCookie, BadHeaderError, JsonResponse, parse_cookie) from django.test import TestCase +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import smart_str, force_text from django.utils.functional import lazy from django.utils._os import upath @@ -561,7 +562,7 @@ class FileCloseTests(TestCase): r = HttpResponse(file1) self.assertFalse(file1.closed) with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInDjango18Warning) list(r) self.assertFalse(file1.closed) r.close() diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py index 7653008336..9cda309bfb 100644 --- a/tests/middleware/tests.py +++ b/tests/middleware/tests.py @@ -21,6 +21,7 @@ from django.middleware.transaction import TransactionMiddleware from django.test import TransactionTestCase, TestCase, RequestFactory, override_settings from django.test.utils import IgnoreDeprecationWarningsMixin from django.utils import six +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_str from django.utils.six.moves import xrange @@ -249,7 +250,7 @@ class CommonMiddlewareTest(TestCase): request = self._get_request('regular_url/that/does/not/exist') request.META['HTTP_REFERER'] = '/another/url/' with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInDjango18Warning) response = self.client.get(request.path) CommonMiddleware().process_response(request, response) self.assertEqual(len(mail.outbox), 1) @@ -261,7 +262,7 @@ class CommonMiddlewareTest(TestCase): def test_404_error_reporting_no_referer(self): request = self._get_request('regular_url/that/does/not/exist') with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInDjango18Warning) response = self.client.get(request.path) CommonMiddleware().process_response(request, response) self.assertEqual(len(mail.outbox), 0) @@ -273,7 +274,7 @@ class CommonMiddlewareTest(TestCase): request = self._get_request('foo_url/that/does/not/exist/either') request.META['HTTP_REFERER'] = '/another/url/' with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInDjango18Warning) response = self.client.get(request.path) CommonMiddleware().process_response(request, response) self.assertEqual(len(mail.outbox), 0) diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index c75921c6e3..e651ddae7d 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -13,8 +13,9 @@ from django.core.validators import ValidationError from django.db import connection from django.db.models.query import EmptyQuerySet from django.forms.models import model_to_dict -from django.utils._os import upath from django.test import TestCase, skipUnlessDBFeature +from django.utils.deprecation import RemovedInDjango18Warning +from django.utils._os import upath from django.utils import six from .models import (Article, ArticleStatus, BetterWriter, BigInt, Book, @@ -265,7 +266,7 @@ class ModelFormBaseTest(TestCase): def test_missing_fields_attribute(self): with warnings.catch_warnings(record=True): - warnings.simplefilter("always", DeprecationWarning) + warnings.simplefilter("always", RemovedInDjango18Warning) class MissingFieldsForm(forms.ModelForm): class Meta: @@ -275,7 +276,7 @@ class ModelFormBaseTest(TestCase): # if a warning has been seen already, the catch_warnings won't # have recorded it. The following line therefore will not work reliably: - # self.assertEqual(w[0].category, DeprecationWarning) + # self.assertEqual(w[0].category, RemovedInDjango18Warning) # Until end of the deprecation cycle, should still create the # form as before: diff --git a/tests/model_forms_regress/tests.py b/tests/model_forms_regress/tests.py index 2d115f515b..2e6bdc4b31 100644 --- a/tests/model_forms_regress/tests.py +++ b/tests/model_forms_regress/tests.py @@ -9,8 +9,9 @@ from django.core.exceptions import FieldError, ValidationError from django.core.files.uploadedfile import SimpleUploadedFile from django.forms.models import (modelform_factory, ModelChoiceField, fields_for_model, construct_instance, ModelFormMetaclass) -from django.utils import six from django.test import TestCase +from django.utils import six +from django.utils.deprecation import RemovedInDjango18Warning from .models import (Person, RealPerson, Triple, FilePathModel, Article, Publication, CustomFF, Author, Author1, Homepage, Document, Edition) @@ -593,10 +594,10 @@ class CustomMetaclassTestCase(TestCase): class TestTicket19733(TestCase): def test_modelform_factory_without_fields(self): with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always", DeprecationWarning) + warnings.simplefilter("always", RemovedInDjango18Warning) # This should become an error once deprecation cycle is complete. modelform_factory(Person) - self.assertEqual(w[0].category, DeprecationWarning) + self.assertEqual(w[0].category, RemovedInDjango18Warning) def test_modelform_factory_with_all_fields(self): form = modelform_factory(Person, fields="__all__") diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py index 205e1dc8cf..1f4fd4e86d 100644 --- a/tests/modeladmin/tests.py +++ b/tests/modeladmin/tests.py @@ -16,6 +16,7 @@ from django.core.exceptions import ImproperlyConfigured from django.forms.models import BaseModelFormSet from django.forms.widgets import Select from django.test import TestCase +from django.utils.deprecation import RemovedInDjango19Warning from .models import Band, Concert, ValidationTestModel, ValidationTestInlineModel @@ -1479,7 +1480,7 @@ class CustomModelAdminTests(CheckTestCase): def test_deprecation(self): "Deprecated Custom Validator definitions still work with the check framework." with warnings.catch_warnings(): - warnings.simplefilter("ignore", category=PendingDeprecationWarning) + warnings.simplefilter("ignore", category=RemovedInDjango19Warning) class CustomValidator(ModelAdminValidator): def validate_me(self, model_admin, model): diff --git a/tests/runtests.py b/tests/runtests.py index 85a73d2e5c..0b065ea951 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -11,9 +11,14 @@ import warnings import django from django import contrib +from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning from django.utils._os import upath from django.utils import six + +warnings.simplefilter("default", RemovedInDjango19Warning) +warnings.simplefilter("default", RemovedInDjango18Warning) + CONTRIB_MODULE_PATH = 'django.contrib' TEST_TEMPLATE_DIR = 'templates' @@ -124,12 +129,12 @@ def setup(verbosity, test_labels): warnings.filterwarnings( 'ignore', 'django.contrib.comments is deprecated and will be removed before Django 1.8.', - DeprecationWarning + RemovedInDjango18Warning ) warnings.filterwarnings( 'ignore', 'Model class django.contrib.comments.models.* Django 1.9.', - PendingDeprecationWarning + RemovedInDjango19Warning ) # Load all the ALWAYS_INSTALLED_APPS. django.setup() @@ -216,7 +221,7 @@ def django_tests(verbosity, interactive, failfast, test_labels): 'ignore', "Custom SQL location '/models/sql' is deprecated, " "use '/sql' instead.", - PendingDeprecationWarning + RemovedInDjango19Warning ) failures = test_runner.run_tests( test_labels or get_installed(), extra_tests=extra_tests) diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index cfe2b5b480..d8aab34571 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -23,6 +23,7 @@ from django.template.loaders import app_directories, filesystem, cached from django.test import RequestFactory, TestCase from django.test.utils import (setup_test_template_loader, restore_template_loaders, override_settings, extend_sys_path) +from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning from django.utils.encoding import python_2_unicode_compatible from django.utils.formats import date_format from django.utils._os import upath @@ -599,9 +600,9 @@ class TemplateTests(TestCase): try: with warnings.catch_warnings(): # Ignore deprecations of the old syntax of the 'cycle' and 'firstof' tags. - warnings.filterwarnings("ignore", category=DeprecationWarning, module='django.template.base') + warnings.filterwarnings("ignore", category=RemovedInDjango18Warning, module='django.template.base') # Ignore pending deprecations of loading 'ssi' and 'url' tags from future. - warnings.filterwarnings("ignore", category=PendingDeprecationWarning, module='django.templatetags.future') + warnings.filterwarnings("ignore", category=RemovedInDjango19Warning, module='django.templatetags.future') test_template = loader.get_template(name) except ShouldNotExecuteException: failures.append("Template test (Cached='%s', TEMPLATE_STRING_IF_INVALID='%s', TEMPLATE_DEBUG=%s): %s -- FAILED. Template loading invoked method that shouldn't have been invoked." % (is_cached, invalid_str, template_debug, name)) diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py index 3f316e1a8b..51ff38d190 100644 --- a/tests/utils_tests/test_html.py +++ b/tests/utils_tests/test_html.py @@ -8,6 +8,7 @@ import warnings from django.utils import html, safestring from django.utils._os import upath +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_text @@ -132,7 +133,7 @@ class TestUtilsHtml(TestCase): def test_fix_ampersands(self): with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInDjango18Warning) f = html.fix_ampersands # Strings without ampersands or with ampersands already encoded. values = ("a", "b", "&a;", "& &x; ", "asdf") @@ -177,7 +178,7 @@ class TestUtilsHtml(TestCase): ('

* foo

* bar

', '
    \n
  • foo
  • bar
  • \n
'), ) with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInDjango18Warning) for value, output in items: self.check_output(f, value, output) diff --git a/tests/utils_tests/test_module_loading.py b/tests/utils_tests/test_module_loading.py index 2eb01ad770..48ba9c15ff 100644 --- a/tests/utils_tests/test_module_loading.py +++ b/tests/utils_tests/test_module_loading.py @@ -10,6 +10,7 @@ from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase, modify_settings from django.test.utils import IgnorePendingDeprecationWarningsMixin, extend_sys_path from django.utils import six +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.module_loading import (autodiscover_modules, import_by_path, import_string, module_has_submodule) from django.utils._os import upath @@ -134,11 +135,11 @@ class ModuleImportTestCase(IgnorePendingDeprecationWarningsMixin, unittest.TestC def test_import_by_path_pending_deprecation_warning(self): with warnings.catch_warnings(record=True) as w: - warnings.simplefilter('always', category=PendingDeprecationWarning) + warnings.simplefilter('always', category=RemovedInDjango19Warning) cls = import_by_path('django.utils.module_loading.import_by_path') self.assertEqual(cls, import_by_path) self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[-1].category, PendingDeprecationWarning)) + self.assertTrue(issubclass(w[-1].category, RemovedInDjango19Warning)) self.assertIn('deprecated', str(w[-1].message)) def test_import_string(self): diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py index e62e4bd621..4015556bae 100644 --- a/tests/utils_tests/test_text.py +++ b/tests/utils_tests/test_text.py @@ -6,6 +6,7 @@ import warnings from django.test import SimpleTestCase from django.utils import six, text +from django.utils.deprecation import RemovedInDjango19Warning IS_WIDE_BUILD = (len('\U0001F4A9') == 1) @@ -154,7 +155,7 @@ class TestUtilsText(SimpleTestCase): input = "" output = r"" output = r"