Commit 640a5da5 authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[trac1021] apply same patch to other lines which use xml.etree.ElementTree.tostring

parent 10e4a07a
......@@ -385,7 +385,14 @@ class StatsHttpd:
annotation.append(documentation)
element.append(annotation)
xsd_root.append(element)
xsd_string = xml.etree.ElementTree.tostring(xsd_root)
# The coding conversion is tricky. xml..tostring() of Python 3.2
# returns bytes (not string) regardless of the coding, while
# tostring() of Python 3.1 returns a string. To support both
# cases transparently, we first make sure tostring() returns
# bytes by specifying utf-8 and then convert the result to a
# plain string (code below assume it).
xsd_string = str(xml.etree.ElementTree.tostring(xsd_root, encoding='utf-8'),
encoding='us-ascii')
self.xsd_body = self.open_template(XSD_TEMPLATE_LOCATION).substitute(
xsd_string=xsd_string,
xsd_namespace=XSD_NAMESPACE
......@@ -410,7 +417,14 @@ class StatsHttpd:
tr.append(td1)
tr.append(td2)
xsd_root.append(tr)
xsl_string = xml.etree.ElementTree.tostring(xsd_root)
# The coding conversion is tricky. xml..tostring() of Python 3.2
# returns bytes (not string) regardless of the coding, while
# tostring() of Python 3.1 returns a string. To support both
# cases transparently, we first make sure tostring() returns
# bytes by specifying utf-8 and then convert the result to a
# plain string (code below assume it).
xsl_string = str(xml.etree.ElementTree.tostring(xsd_root, encoding='utf-8'),
encoding='us-ascii')
self.xsl_body = self.open_template(XSL_TEMPLATE_LOCATION).substitute(
xsl_string=xsl_string,
xsd_namespace=XSD_NAMESPACE)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment