summaryrefslogtreecommitdiff
path: root/Lib/xml/etree/ElementTree.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-09-23 01:49:24 +0000
committerMartin Panter <vadmium+py@gmail.com>2015-09-23 01:49:24 +0000
commitf9cd8ff14a5830819552b14613f49a196e9d73b6 (patch)
tree300756bc7b5930498b7f1710e3dfd267ba66b618 /Lib/xml/etree/ElementTree.py
parentebbad80e85e8f33b2cbb183fc26c615b7f3730e2 (diff)
parent982a08f8bb0e5df633cd502f86c0f1d019497e80 (diff)
downloadcpython-git-f9cd8ff14a5830819552b14613f49a196e9d73b6.tar.gz
Issue #25047: Merge Element Tree encoding from 3.5
Diffstat (limited to 'Lib/xml/etree/ElementTree.py')
-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 4c109a2f61..bb32a8f03b 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()