Author vstinner
Recipients vstinner
Date 2016-09-02.10:57:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.
Date User Action Args
2016-09-02 10:57:59vstinnersetrecipients: + vstinner
2016-09-02 10:57:59vstinnersetmessageid: <>
2016-09-02 10:57:59vstinnerlinkissue27940 messages
2016-09-02 10:57:59vstinnercreate