summaryrefslogtreecommitdiff
path: root/xml_helper.py
diff options
context:
space:
mode:
authorKelly Anderson <kelly@xilka.com>2013-03-29 19:23:35 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-29 20:30:22 -0400
commit95e3faefe2e262fdfe3beaa2b344ad12372b8af0 (patch)
tree70d38762d13d42dcd9ef425e18fd6cc64da74287 /xml_helper.py
parent1a13e31d275430ffba713c8a68ee7f22093c29e0 (diff)
build-sys: force Python to write UTF-8
Here is a patch that fixes documentation with python 3.x in non utf-8 locales. Specifically in my locale latin-1 is the default setting for output going to stdout, which causes it to fail. By writing directly to file we are able to set the locale to utf-8.
Diffstat (limited to 'xml_helper.py')
-rw-r--r--xml_helper.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/xml_helper.py b/xml_helper.py
index a484beac19..08e226fa21 100644
--- a/xml_helper.py
+++ b/xml_helper.py
@@ -28,7 +28,8 @@ try:
_parser = tree.XMLParser()
_parser.resolvers.add(CustomResolver())
xml_parse = lambda page: tree.parse(page, _parser)
- xml_print = lambda xml: tree.tostring(xml, pretty_print=True)
+ xml_print = lambda xml: tree.tostring(xml, pretty_print=True,
+ encoding='utf-8')
except ImportError:
import xml.etree.ElementTree as tree
import re as _re
@@ -37,4 +38,4 @@ except ImportError:
def xml_parse(page):
s = _re.sub(b'&[a-zA-Z0-9_]+;', b'', open(page, 'rb').read())
return tree.parse(_io.BytesIO(s))
- xml_print = tree.tostring
+ xml_print = lambda xml: tree.tostring(xml, encoding='utf-8')