diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-07-21 10:00:10 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-07 12:00:22 +0200 |
| commit | c5ef65bcf324f4c90b53be90f4aec069a68e8c59 (patch) | |
| tree | bb9a4988fbae4e7366cc578ca845c49003cdcd64 /django/utils/feedgenerator.py | |
| parent | ee191715eae73362768184aa95206cf61bac5d38 (diff) | |
[py3] Ported django.utils.encoding.
* Renamed smart_unicode to smart_text (but kept the old name under
Python 2 for backwards compatibility).
* Renamed smart_str to smart_bytes.
* Re-introduced smart_str as an alias for smart_text under Python 3
and smart_bytes under Python 2 (which is backwards compatible).
Thus smart_str always returns a str objects.
* Used the new smart_str in a few places where both Python 2 and 3
want a str.
Diffstat (limited to 'django/utils/feedgenerator.py')
| -rw-r--r-- | django/utils/feedgenerator.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index 6498aaf57c..1bf43bf0a7 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -29,7 +29,7 @@ try: except ImportError: # Python 2 from urlparse import urlparse from django.utils.xmlutils import SimplerXMLGenerator -from django.utils.encoding import force_unicode, iri_to_uri +from django.utils.encoding import force_text, iri_to_uri from django.utils import datetime_safe from django.utils.timezone import is_aware @@ -81,12 +81,12 @@ class SyndicationFeed(object): def __init__(self, title, link, description, language=None, author_email=None, author_name=None, author_link=None, subtitle=None, categories=None, feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs): - to_unicode = lambda s: force_unicode(s, strings_only=True) + to_unicode = lambda s: force_text(s, strings_only=True) if categories: - categories = [force_unicode(c) for c in categories] + categories = [force_text(c) for c in categories] if ttl is not None: # Force ints to unicode - ttl = force_unicode(ttl) + ttl = force_text(ttl) self.feed = { 'title': to_unicode(title), 'link': iri_to_uri(link), @@ -114,12 +114,12 @@ class SyndicationFeed(object): objects except pubdate, which is a datetime.datetime object, and enclosure, which is an instance of the Enclosure class. """ - to_unicode = lambda s: force_unicode(s, strings_only=True) + to_unicode = lambda s: force_text(s, strings_only=True) if categories: categories = [to_unicode(c) for c in categories] if ttl is not None: # Force ints to unicode - ttl = force_unicode(ttl) + ttl = force_text(ttl) item = { 'title': to_unicode(title), 'link': iri_to_uri(link), |
