summaryrefslogtreecommitdiff
path: root/django/utils/feedgenerator.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2017-04-27 09:31:08 +0200
committerClaude Paroz <claude@2xlibre.net>2017-04-27 09:31:08 +0200
commita8343fe7bf0ec237d8f77ba4e729ae093388b75f (patch)
tree4d10d0489a088f78d20b9591199d22179a3bb083 /django/utils/feedgenerator.py
parent301de774c21d055e9e5a7073e5bffdb52bc71079 (diff)
Refs #27795 -- Replaced force_text() with str() in feed generators
Diffstat (limited to 'django/utils/feedgenerator.py')
-rw-r--r--django/utils/feedgenerator.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index fa5c1f03ba..3b38eb5ed9 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -26,7 +26,7 @@ from io import StringIO
from urllib.parse import urlparse
from django.utils import datetime_safe
-from django.utils.encoding import force_text, iri_to_uri
+from django.utils.encoding import iri_to_uri
from django.utils.timezone import utc
from django.utils.xmlutils import SimplerXMLGenerator
@@ -85,12 +85,9 @@ class SyndicationFeed:
author_name=None, author_link=None, subtitle=None, categories=None,
feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs):
def to_str(s):
- return force_text(s, strings_only=True)
+ return str(s) if s is not None else s
if categories:
- categories = [force_text(c) for c in categories]
- if ttl is not None:
- # Force ints to str
- ttl = force_text(ttl)
+ categories = [str(c) for c in categories]
self.feed = {
'title': to_str(title),
'link': iri_to_uri(link),
@@ -104,7 +101,7 @@ class SyndicationFeed:
'feed_url': iri_to_uri(feed_url),
'feed_copyright': to_str(feed_copyright),
'id': feed_guid or link,
- 'ttl': ttl,
+ 'ttl': to_str(ttl),
}
self.feed.update(kwargs)
self.items = []
@@ -119,12 +116,9 @@ class SyndicationFeed:
enclosures, which is an iterable of instances of the Enclosure class.
"""
def to_str(s):
- return force_text(s, strings_only=True)
+ return str(s) if s is not None else s
if categories:
categories = [to_str(c) for c in categories]
- if ttl is not None:
- # Force ints to str
- ttl = force_text(ttl)
item = {
'title': to_str(title),
'link': iri_to_uri(link),
@@ -140,7 +134,7 @@ class SyndicationFeed:
'enclosures': enclosures or (),
'categories': categories or (),
'item_copyright': to_str(item_copyright),
- 'ttl': ttl,
+ 'ttl': to_str(ttl),
}
item.update(kwargs)
self.items.append(item)