From b6fbf3e8e56b34fdc4367d582bbcb036e4aa2972 Mon Sep 17 00:00:00 2001 From: Pavlo Kapyshin Date: Fri, 24 Feb 2017 16:46:31 +0200 Subject: [PATCH] Fixed #27879 -- Fixed crash if enclosures aren't provided to Atom1Feed.add_item(). Regression in 75cf9b5ac031feb8f94271c9906157c921a14520 --- AUTHORS | 1 + django/utils/feedgenerator.py | 2 +- tests/utils_tests/test_feedgenerator.py | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index e67a9014d1..7932c6c5b6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -612,6 +612,7 @@ answer newbie questions, and generally made Django that much better: Paulo Scardine Paul Smith pavithran s + Pavlo Kapyshin permonik@mesias.brnonet.cz Petar Marić Pete Crosier diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index 9dec126941..fa5c1f03ba 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -137,7 +137,7 @@ class SyndicationFeed: 'comments': to_str(comments), 'unique_id': to_str(unique_id), 'unique_id_is_permalink': unique_id_is_permalink, - 'enclosures': enclosures, + 'enclosures': enclosures or (), 'categories': categories or (), 'item_copyright': to_str(item_copyright), 'ttl': ttl, diff --git a/tests/utils_tests/test_feedgenerator.py b/tests/utils_tests/test_feedgenerator.py index 8c0edb4374..78e4d5b737 100644 --- a/tests/utils_tests/test_feedgenerator.py +++ b/tests/utils_tests/test_feedgenerator.py @@ -120,6 +120,12 @@ class FeedgeneratorTest(unittest.TestCase): self.assertIn('href="/feed/"', feed_content) self.assertIn('rel="self"', feed_content) + def test_atom_add_item(self): + # Not providing any optional arguments to Atom1Feed.add_item() + feed = feedgenerator.Atom1Feed('title', '/link/', 'descr') + feed.add_item('item_title', 'item_link', 'item_description') + feed.writeString('utf-8') + class FeedgeneratorDBTest(TestCase):