summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-09-23 01:43:08 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-09-23 01:43:08 (GMT)
commit982a08f8bb0e5df633cd502f86c0f1d019497e80 (patch)
treeacfd5dd7e5f6bbf04b26e93dd9800b7aecc1a17f /Lib/xml
parent5f62112db409627deb3095297fa5fe0d60340a9b (diff)
parent89f76d3f913e0527fbcc0d15cb3c17fbf6ca8618 (diff)
downloadcpython-982a08f8bb0e5df633cd502f86c0f1d019497e80.zip
cpython-982a08f8bb0e5df633cd502f86c0f1d019497e80.tar.gz
cpython-982a08f8bb0e5df633cd502f86c0f1d019497e80.tar.bz2
Issue #25047: Merge Element Tree encoding from 3.4 into 3.5
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/etree/ElementTree.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 4c109a2..bb32a8f 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -752,14 +752,13 @@ class ElementTree:
encoding = "utf-8"
else:
encoding = "us-ascii"
- else:
- encoding = encoding.lower()
- with _get_writer(file_or_filename, encoding) as write:
+ enc_lower = encoding.lower()
+ with _get_writer(file_or_filename, enc_lower) as write:
if method == "xml" and (xml_declaration or
(xml_declaration is None and
- encoding not in ("utf-8", "us-ascii", "unicode"))):
+ enc_lower not in ("utf-8", "us-ascii", "unicode"))):
declared_encoding = encoding
- if encoding == "unicode":
+ if enc_lower == "unicode":
# Retrieve the default encoding for the xml declaration
import locale
declared_encoding = locale.getpreferredencoding()