Refs #27795 -- Replaced force_text() with str() in feed generators
This commit is contained in:
parent
301de774c2
commit
a8343fe7bf
|
@ -26,7 +26,7 @@ from io import StringIO
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from django.utils import datetime_safe
|
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.timezone import utc
|
||||||
from django.utils.xmlutils import SimplerXMLGenerator
|
from django.utils.xmlutils import SimplerXMLGenerator
|
||||||
|
|
||||||
|
@ -85,12 +85,9 @@ class SyndicationFeed:
|
||||||
author_name=None, author_link=None, subtitle=None, categories=None,
|
author_name=None, author_link=None, subtitle=None, categories=None,
|
||||||
feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs):
|
feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs):
|
||||||
def to_str(s):
|
def to_str(s):
|
||||||
return force_text(s, strings_only=True)
|
return str(s) if s is not None else s
|
||||||
if categories:
|
if categories:
|
||||||
categories = [force_text(c) for c in categories]
|
categories = [str(c) for c in categories]
|
||||||
if ttl is not None:
|
|
||||||
# Force ints to str
|
|
||||||
ttl = force_text(ttl)
|
|
||||||
self.feed = {
|
self.feed = {
|
||||||
'title': to_str(title),
|
'title': to_str(title),
|
||||||
'link': iri_to_uri(link),
|
'link': iri_to_uri(link),
|
||||||
|
@ -104,7 +101,7 @@ class SyndicationFeed:
|
||||||
'feed_url': iri_to_uri(feed_url),
|
'feed_url': iri_to_uri(feed_url),
|
||||||
'feed_copyright': to_str(feed_copyright),
|
'feed_copyright': to_str(feed_copyright),
|
||||||
'id': feed_guid or link,
|
'id': feed_guid or link,
|
||||||
'ttl': ttl,
|
'ttl': to_str(ttl),
|
||||||
}
|
}
|
||||||
self.feed.update(kwargs)
|
self.feed.update(kwargs)
|
||||||
self.items = []
|
self.items = []
|
||||||
|
@ -119,12 +116,9 @@ class SyndicationFeed:
|
||||||
enclosures, which is an iterable of instances of the Enclosure class.
|
enclosures, which is an iterable of instances of the Enclosure class.
|
||||||
"""
|
"""
|
||||||
def to_str(s):
|
def to_str(s):
|
||||||
return force_text(s, strings_only=True)
|
return str(s) if s is not None else s
|
||||||
if categories:
|
if categories:
|
||||||
categories = [to_str(c) for c in categories]
|
categories = [to_str(c) for c in categories]
|
||||||
if ttl is not None:
|
|
||||||
# Force ints to str
|
|
||||||
ttl = force_text(ttl)
|
|
||||||
item = {
|
item = {
|
||||||
'title': to_str(title),
|
'title': to_str(title),
|
||||||
'link': iri_to_uri(link),
|
'link': iri_to_uri(link),
|
||||||
|
@ -140,7 +134,7 @@ class SyndicationFeed:
|
||||||
'enclosures': enclosures or (),
|
'enclosures': enclosures or (),
|
||||||
'categories': categories or (),
|
'categories': categories or (),
|
||||||
'item_copyright': to_str(item_copyright),
|
'item_copyright': to_str(item_copyright),
|
||||||
'ttl': ttl,
|
'ttl': to_str(ttl),
|
||||||
}
|
}
|
||||||
item.update(kwargs)
|
item.update(kwargs)
|
||||||
self.items.append(item)
|
self.items.append(item)
|
||||||
|
|
Loading…
Reference in New Issue