diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index a27eb1f2e93..d8a932b0200 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -24,10 +24,8 @@ http://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004/ from __future__ import unicode_literals import datetime -import warnings from django.utils import datetime_safe, six -from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text, iri_to_uri from django.utils.six import StringIO from django.utils.six.moves.urllib.parse import urlparse @@ -119,9 +117,8 @@ class SyndicationFeed(object): def add_item(self, title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, - unique_id=None, unique_id_is_permalink=None, enclosure=None, - categories=(), item_copyright=None, ttl=None, updateddate=None, - enclosures=None, **kwargs): + unique_id=None, unique_id_is_permalink=None, categories=(), + item_copyright=None, ttl=None, updateddate=None, enclosures=None, **kwargs): """ Adds an item to the feed. All args are expected to be Python Unicode objects except pubdate and updateddate, which are datetime.datetime @@ -135,16 +132,6 @@ class SyndicationFeed(object): if ttl is not None: # Force ints to unicode ttl = force_text(ttl) - if enclosure is None: - enclosures = [] if enclosures is None else enclosures - else: - warnings.warn( - "The enclosure keyword argument is deprecated, " - "use enclosures instead.", - RemovedInDjango20Warning, - stacklevel=2, - ) - enclosures = [enclosure] item = { 'title': to_unicode(title), 'link': iri_to_uri(link), diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt index 25851c94a39..3552f70f291 100644 --- a/docs/ref/contrib/syndication.txt +++ b/docs/ref/contrib/syndication.txt @@ -963,7 +963,6 @@ They share this interface: * ``pubdate`` * ``comments`` * ``unique_id`` - * ``enclosure`` * ``enclosures`` * ``categories`` * ``item_copyright`` @@ -976,17 +975,10 @@ They share this interface: * ``pubdate`` should be a Python :class:`~datetime.datetime` object. * ``updateddate`` should be a Python :class:`~datetime.datetime` object. - * ``enclosure`` should be an instance of - :class:`django.utils.feedgenerator.Enclosure`. * ``enclosures`` should be a list of :class:`django.utils.feedgenerator.Enclosure` instances. * ``categories`` should be a sequence of Unicode objects. - .. deprecated:: 1.9 - - The ``enclosure`` keyword argument is deprecated in favor of the - ``enclosures`` keyword argument. - :meth:`.SyndicationFeed.write` Outputs the feed in the given encoding to outfile, which is a file-like object. diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 18561781c1c..1105dc9a169 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -353,18 +353,11 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004 All parameters should be Unicode objects, except ``categories``, which should be a sequence of Unicode objects. - .. method:: add_item(title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None, updateddate=None, enclosures=None, **kwargs) + .. method:: add_item(title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, categories=(), item_copyright=None, ttl=None, updateddate=None, enclosures=None, **kwargs) Adds an item to the feed. All args are expected to be Python ``unicode`` objects except ``pubdate`` and ``updateddate``, which are ``datetime.datetime`` - objects, ``enclosure``, which is an ``Enclosure`` instance, and - ``enclosures``, which is a list of ``Enclosure`` instances. - - .. deprecated:: 1.9 - - The ``enclosure`` keyword argument is deprecated in favor of the - new ``enclosures`` keyword argument which accepts a list of - ``Enclosure`` objects. + objects, and ``enclosures``, which is a list of ``Enclosure`` instances. .. method:: num_items() diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index 311a3d6da44..13a47840c37 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -312,3 +312,6 @@ these features. * Support for the ``allow_tags`` attribute on ``ModelAdmin`` methods is removed. + +* The ``enclosure`` keyword argument to ``SyndicationFeed.add_item()`` is + removed. diff --git a/tests/syndication_tests/tests.py b/tests/syndication_tests/tests.py index f8948ac21d7..0fb860474cf 100644 --- a/tests/syndication_tests/tests.py +++ b/tests/syndication_tests/tests.py @@ -9,10 +9,7 @@ from django.core.exceptions import ImproperlyConfigured from django.test import TestCase, override_settings from django.test.utils import requires_tz_support from django.utils import timezone -from django.utils.deprecation import RemovedInDjango20Warning -from django.utils.feedgenerator import ( - Enclosure, SyndicationFeed, rfc2822_date, rfc3339_date, -) +from django.utils.feedgenerator import rfc2822_date, rfc3339_date from .models import Article, Entry @@ -520,16 +517,3 @@ class SyndicationFeedTest(FeedTestCase): views.add_domain('example.com', '//example.com/foo/?arg=value'), 'http://example.com/foo/?arg=value' ) - - -class FeedgeneratorTestCase(TestCase): - def test_add_item_warns_when_enclosure_kwarg_is_used(self): - feed = SyndicationFeed(title='Example', link='http://example.com', description='Foo') - msg = 'The enclosure keyword argument is deprecated, use enclosures instead.' - with self.assertRaisesMessage(RemovedInDjango20Warning, msg): - feed.add_item( - title='Example Item', - link='https://example.com/item', - description='bar', - enclosure=Enclosure('http://example.com/favicon.ico', 0, 'image/png'), - )