Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #8219 -- More robust date to string conversion in syndication f…


(Sometimes) Affects people running in locales that use non-ASCII date strings.
Patch from alperkanat.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3b45a40c54993a36e2e56448326553e46a1b40d7 1 parent f67fb60
@malcolmt malcolmt authored
Showing with 12 additions and 12 deletions.
  1. +12 −12 django/utils/
24 django/utils/
@@ -81,7 +81,7 @@ def __init__(self, title, link, description, language=None, author_email=None,
def add_item(self, 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,
+ unique_id=None, enclosure=None, categories=(), item_copyright=None,
ttl=None, **kwargs):
Adds an item to the feed. All args are expected to be Python Unicode
@@ -118,26 +118,26 @@ def root_attributes(self):
Called from write().
return {}
def add_root_elements(self, handler):
- Add elements in the the root (i.e. feed/channel) element. Called
+ Add elements in the the root (i.e. feed/channel) element. Called
from write().
def item_attributes(self, item):
Return extra attributes to place on each item (i.e. item/entry) element.
return {}
def add_item_elements(self, handler, item):
Add elements on each item (i.e. item/entry) element.
def write(self, outfile, encoding):
Outputs the feed in the given encoding to outfile, which is a file-like
@@ -204,7 +204,7 @@ def add_root_elements(self, handler):
handler.addQuickElement(u"category", cat)
if self.feed['feed_copyright'] is not None:
handler.addQuickElement(u"copyright", self.feed['feed_copyright'])
- handler.addQuickElement(u"lastBuildDate", rfc2822_date(self.latest_post_date()).decode('ascii'))
+ handler.addQuickElement(u"lastBuildDate", rfc2822_date(self.latest_post_date()).decode('utf-8'))
if self.feed['ttl'] is not None:
handler.addQuickElement(u"ttl", self.feed['ttl'])
@@ -238,7 +238,7 @@ def add_item_elements(self, handler, item):
handler.addQuickElement(u"dc:creator", item["author_name"], {"xmlns:dc": u""})
if item['pubdate'] is not None:
- handler.addQuickElement(u"pubDate", rfc2822_date(item['pubdate']).decode('ascii'))
+ handler.addQuickElement(u"pubDate", rfc2822_date(item['pubdate']).decode('utf-8'))
if item['comments'] is not None:
handler.addQuickElement(u"comments", item['comments'])
if item['unique_id'] is not None:
@@ -281,7 +281,7 @@ def add_root_elements(self, handler):
if self.feed['feed_url'] is not None:
handler.addQuickElement(u"link", "", {u"rel": u"self", u"href": self.feed['feed_url']})
handler.addQuickElement(u"id", self.feed['id'])
- handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('ascii'))
+ handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('utf-8'))
if self.feed['author_name'] is not None:
handler.startElement(u"author", {})
handler.addQuickElement(u"name", self.feed['author_name'])
@@ -296,18 +296,18 @@ def add_root_elements(self, handler):
handler.addQuickElement(u"category", "", {u"term": cat})
if self.feed['feed_copyright'] is not None:
handler.addQuickElement(u"rights", self.feed['feed_copyright'])
def write_items(self, handler):
for item in self.items:
handler.startElement(u"entry", self.item_attributes(item))
self.add_item_elements(handler, item)
def add_item_elements(self, handler, item):
handler.addQuickElement(u"title", item['title'])
handler.addQuickElement(u"link", u"", {u"href": item['link'], u"rel": u"alternate"})
if item['pubdate'] is not None:
- handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('ascii'))
+ handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('utf-8'))
# Author information.
if item['author_name'] is not None:
Please sign in to comment.
Something went wrong with that request. Please try again.