New submission from STINNER Victor:

The ElementTree module (xml.etree) avoids the XML declaration for "utf-8" and 
"us-ascii" codecs, but not for the "ascii" encoding.

Attached patch avoids the XML declaration for the "ascii" codec since it's a 
subset of UTF-8 and UTF-8 is the default encoding of XML.

The patch also normalizes the encoding name to handle aliases like "utf8" 
(UTF-8) or "us_ascii" (ASCII).

The patch adds unit tests.

--

By the way, I'm surprised that the special encoding "unicode" relies on the 
*current* locale encoding when the XML declaration is requested. Why not alway 
susing UTF-8 for *unicode* instead of the locale encoding?

My unit test tests different locale encodings.

----------
components: XML
files: etree_xml_declaration.patch
keywords: patch
messages: 274227
nosy: haypo
priority: normal
severity: normal
status: open
title: xml.etree: Avoid XML declaration for the "ascii" encoding
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file44346/etree_xml_declaration.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27940>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to