[New-bugs-announce] [issue35428] xml.etree.ElementTree.tostring violates W3 standards allowing encoding='unicode' without error

EZ report at bugs.python.org
Thu Dec 6 13:08:42 EST 2018

New submission from EZ <psizzlepip at yahoo.com>:

The documentation[0] for 3.x of xml.etree.ElementTree.tostring is quite clear:

> Use encoding="unicode" to generate a Unicode string.

See also the creation of the problem:

This is a violation of W3 standards, referenced by the ElementTree documentation[1] claiming it must conform to these standards, which state:

...it is a fatal error for an entity including an encoding declaration to be presented to the XML processor in an encoding other than that named in the declaration....

Encoding for 'unicode' does not appear in the named declarations (https://www.iana.org/assignments/character-sets/character-sets.xhtml) referenced by the same documentation[1].

Handling of a fatal error, must, in part: 

Once a fatal error is detected, however, the processor MUST NOT continue normal processing (i.e., it MUST NOT continue to pass character data and information about the document's logical structure to the application in the normal way)

[0] https://docs.python.org/3.2/library/xml.etree.elementtree.html
[1] The encoding string included in XML output should conform to the appropriate standards. For example, “UTF-8” is valid, but “UTF8” is not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl and http://www.iana.org/assignments/character-sets.

components: XML
messages: 331242
nosy: Zim
priority: normal
severity: normal
status: open
title: xml.etree.ElementTree.tostring violates W3 standards allowing encoding='unicode' without error
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list