Permalink
Browse files

Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX …

…warnings

Thanks Anssi Kääriäinen for the idea and Simon Charette for the
review.
  • Loading branch information...
claudep committed Feb 26, 2014
1 parent 70ec4d7 commit 210d0489c5daad56b806f8165f9fe09fb3c2a019
Showing with 287 additions and 189 deletions.
  1. +10 −9 django/apps/registry.py
  2. +2 −1 django/conf/urls/shortcut.py
  3. +14 −13 django/contrib/admin/options.py
  4. +3 −1 django/contrib/admin/util.py
  5. +5 −5 django/contrib/admin/views/main.py
  6. +2 −1 django/contrib/admindocs/views.py
  7. +4 −1 django/contrib/comments/__init__.py
  8. +2 −2 django/contrib/comments/templatetags/comments.py
  9. +2 −2 django/contrib/contenttypes/fields.py
  10. +2 −1 django/contrib/contenttypes/generic.py
  11. +3 −1 django/contrib/gis/db/backends/util.py
  12. +3 −2 django/contrib/gis/sitemaps/views.py
  13. +4 −3 django/contrib/sites/models.py
  14. +2 −1 django/core/cache/__init__.py
  15. +2 −3 django/core/cache/backends/memcached.py
  16. +2 −1 django/core/handlers/wsgi.py
  17. +3 −2 django/core/management/base.py
  18. +2 −1 django/core/management/commands/dumpdata.py
  19. +2 −1 django/core/management/commands/runfcgi.py
  20. +3 −1 django/core/management/commands/syncdb.py
  21. +2 −1 django/core/management/commands/validate.py
  22. +2 −1 django/core/management/sql.py
  23. +2 −1 django/core/serializers/base.py
  24. +3 −2 django/db/__init__.py
  25. +1 −1 django/db/backends/__init__.py
  26. +2 −1 django/db/backends/creation.py
  27. +3 −1 django/db/backends/util.py
  28. +2 −1 django/db/models/__init__.py
  29. +5 −4 django/db/models/base.py
  30. +2 −1 django/db/models/fields/__init__.py
  31. +3 −3 django/db/models/fields/related.py
  32. +3 −1 django/db/models/loading.py
  33. +3 −3 django/db/models/manager.py
  34. +6 −5 django/db/models/options.py
  35. +6 −5 django/db/models/sql/query.py
  36. +3 −2 django/db/models/sql/where.py
  37. +8 −7 django/db/transaction.py
  38. +3 −2 django/db/utils.py
  39. +3 −2 django/forms/fields.py
  40. +4 −3 django/forms/forms.py
  41. +7 −5 django/forms/models.py
  42. +3 −1 django/forms/util.py
  43. +3 −2 django/forms/utils.py
  44. +4 −3 django/forms/widgets.py
  45. +2 −1 django/middleware/cache.py
  46. +2 −1 django/middleware/common.py
  47. +4 −1 django/middleware/doc.py
  48. +2 −1 django/middleware/transaction.py
  49. +3 −2 django/template/defaulttags.py
  50. +3 −2 django/templatetags/future.py
  51. +4 −2 django/test/_doctest.py
  52. +2 −1 django/test/simple.py
  53. +5 −7 django/test/utils.py
  54. +4 −2 django/utils/datastructures.py
  55. +8 −0 django/utils/deprecation.py
  56. +3 −1 django/utils/dictconfig.py
  57. +2 −1 django/utils/functional.py
  58. +4 −3 django/utils/html.py
  59. +2 −1 django/utils/image.py
  60. +3 −1 django/utils/importlib.py
  61. +2 −1 django/utils/module_loading.py
  62. +2 −1 django/utils/text.py
  63. +2 −1 django/utils/translation/trans_real.py
  64. +4 −3 django/utils/tzinfo.py
  65. +3 −1 django/utils/unittest.py
  66. +2 −1 django/views/defaults.py
  67. +3 −2 django/views/generic/edit.py
  68. +5 −5 docs/internals/contributing/writing-code/submitting-patches.txt
  69. +6 −7 docs/internals/release-process.txt
  70. +3 −2 tests/defaultfilters/tests.py
  71. +1 −0 tests/deprecation/tests.py
  72. +3 −2 tests/forms_tests/tests/test_widgets.py
  73. +4 −3 tests/generic_views/test_edit.py
  74. +2 −1 tests/httpwrappers/tests.py
  75. +4 −3 tests/middleware/tests.py
  76. +4 −3 tests/model_forms/tests.py
  77. +4 −3 tests/model_forms_regress/tests.py
  78. +2 −1 tests/modeladmin/tests.py
  79. +8 −3 tests/runtests.py
  80. +3 −2 tests/template_tests/tests.py
  81. +3 −2 tests/utils_tests/test_html.py
  82. +3 −2 tests/utils_tests/test_module_loading.py
  83. +3 −2 tests/utils_tests/test_text.py
  84. +3 −1 tests/utils_tests/test_tzinfo.py
View
@@ -6,6 +6,7 @@
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 @@ def get_models(self, app_mod=None, include_auto_created=False,
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 @@ def load_app(self, app_name):
"""
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 @@ def load_app(self, app_name):
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 @@ def get_app(self, app_label):
"""
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 @@ def get_apps(self):
"""
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 @@ def _get_app_package(self, app):
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 @@ def _get_app_path(self, app):
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 @@ def get_app_paths(self):
"""
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 @@ def register_models(self, app_label, *models):
"""
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)
@@ -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<content_type_id>\d+)/(?P<object_id>.*)/$', 'defaults.shortcut'),
@@ -18,7 +18,8 @@
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.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 @@ class IncorrectLookupParameters(Exception):
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 @@ def check(cls, model, **kwargs):
'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 @@ def declared_fieldsets(self):
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 @@ def get_fieldsets(self, request, obj=None):
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 @@ def get_formsets(self, request, obj=None):
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 @@ def get_formsets_with_inlines(self, request, obj=None):
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))
@@ -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
@@ -8,7 +8,7 @@
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,15 +51,15 @@ 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
class RenameChangeListMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', DeprecationWarning),
+ ('get_query_set', 'get_queryset', RemovedInDjango18Warning),
)
@@ -114,14 +114,14 @@ def __init__(self, request, model, list_display, list_display_links,
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):
@@ -15,6 +15,7 @@
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 @@
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)
@@ -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'
@@ -4,15 +4,15 @@
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()
class RenameBaseCommentNodeMethods(RenameMethodsBase):
renamed_methods = (
- ('get_query_set', 'get_queryset', DeprecationWarning),
+ ('get_query_set', 'get_queryset', RemovedInDjango18Warning),
)
@@ -13,13 +13,13 @@
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),
)
@@ -2,11 +2,12 @@
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
@@ -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
@@ -12,6 +12,7 @@
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:
@@ -6,8 +6,9 @@
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)
Oops, something went wrong.

0 comments on commit 210d048

Please sign in to comment.