summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/etree/ElementInclude.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/xml/etree/ElementInclude.py b/Lib/xml/etree/ElementInclude.py
index 84fd754..6cc1b44 100644
--- a/Lib/xml/etree/ElementInclude.py
+++ b/Lib/xml/etree/ElementInclude.py
@@ -67,7 +67,7 @@ class FatalIncludeError(SyntaxError):
#
# @param href Resource reference.
# @param parse Parse mode. Either "xml" or "text".
-# @param encoding Optional text encoding.
+# @param encoding Optional text encoding (UTF-8 by default for "text").
# @return The expanded resource. If the parse mode is "xml", this
# is an ElementTree instance. If the parse mode is "text", this
# is a Unicode string. If the loader fails, it can return None
@@ -75,13 +75,14 @@ class FatalIncludeError(SyntaxError):
# @throws IOError If the loader fails to load the resource.
def default_loader(href, parse, encoding=None):
- file = open(href)
if parse == "xml":
+ file = open(href, 'rb')
data = ElementTree.parse(file).getroot()
else:
+ if not encoding:
+ encoding = 'UTF-8'
+ file = open(href, 'r', encoding=encoding)
data = file.read()
- if encoding:
- data = data.decode(encoding)
file.close()
return data