mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	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.
This commit is contained in:
		| @@ -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): | ||||
|   | ||||
| @@ -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): | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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())) | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user