[New-bugs-announce] [issue9522] xml.etree.ElementTree forgets the encoding

Mark Summerfield report at bugs.python.org
Thu Aug 5 11:32:10 CEST 2010

New submission from Mark Summerfield <mark at qtrac.eu>:

If you read in an XML file that specifies its encoding and then later on use xml.etree.ElementTree.write(), it is always written using US-ASCII. 

I think the behaviour should be different:
(1) If the XML that was read included an encoding, that encoding should be remembered and used when writing.
(2) If there is no encoding the default for writing should be UTF-8 (which is the standard for XML files).
(3) For non-XML files use US-ASCII.

Naturally, any of these could be overridden using an encoding argument to the write() method.

components: Library (Lib)
messages: 112962
nosy: mark
priority: normal
severity: normal
status: open
title: xml.etree.ElementTree forgets the encoding
type: behavior
versions: Python 3.1

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list