Message10367
This seems to be a variation of #1479. To reproduce:
E:\>jython
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.8.0_60
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.etree import ElementTree as ET
>>> elem = ET.XML('<test/>')
>>> tree = ET.ElementTree(elem)
>>> tree.write('test.xml', encoding='blaaaah')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\jython2.7.0\Lib\xml\etree\ElementTree.py", line 818, in write
qnames, namespaces = _namespaces(
File "C:\jython2.7.0\Lib\xml\etree\ElementTree.py", line 886, in _namespaces
add_qname(tag)
File "C:\jython2.7.0\Lib\xml\etree\ElementTree.py", line 870, in add_qname
qnames[qname] = encode(qname)
File "C:\jython2.7.0\Lib\xml\etree\ElementTree.py", line 870, in add_qname
qnames[qname] = encode(qname)
File "C:\jython2.7.0\Lib\xml\etree\ElementTree.py", line 845, in encode
return text.encode(encoding)
LookupError: unknown encoding 'blaaaah'
>>> import os
>>> os.remove('test.xml')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: unlink(): an unknown error occurred: E:\test.xml
A workaround is opening and closing output files explicitly:
with open('test.xml', 'wb') as output:
tree.write(output, ...) |
|
Date |
User |
Action |
Args |
2015-10-21 08:45:50 | pekka.klarck | set | recipients:
+ pekka.klarck |
2015-10-21 08:45:50 | pekka.klarck | set | messageid: <1445417150.72.0.990884776188.issue2413@psf.upfronthosting.co.za> |
2015-10-21 08:45:50 | pekka.klarck | link | issue2413 messages |
2015-10-21 08:45:49 | pekka.klarck | create | |
|