[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread David Buxton
New submission from David Buxton: The problem is an inconsistency between the ElementTree.write() method on Python 2 and 3 when xml_declaration is True. For Python 2.7 the encoding argument MUST NOT be a unicode string. For Python 3.2 the encoding argument MUST be a unicode string. On Python

[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread David Buxton
David Buxton added the comment: A patch against the current default branch to add tests for the xml_declaration keyword argument. This passes when applied to the 2.7 branch too. This does NOT test whether one can use both bytes/unicode for the encoding argument. It just uses the native string

[issue15811] ElementTree.write() raises TypeError when xml_declaration = True and encoding is a unicode string

2012-08-29 Thread David Buxton
David Buxton added the comment: Only a problem because I am using unicode_literals and it didn't occur to me to use `str('utf-8')` to get a native string on both 2+3. Much the best solution, thank you. But that is still a little smelly - I think what I want ideally is for ElementTree