Incorrect value in attribute when use xmlfile.element
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Undecided
|
scoder |
Bug Description
I found that serialization of attributes is different between etree.Element and xmlfile.element if attribute value is not English word
import io
res_file = io.BytesIO()
with etree.xmlfile(
with xf.element(
el = etree.Element(
Result
print(res_
<Документ Тест="&
It looks like attribute value is hex value
Python : sys.version_
lxml.etree : (5, 2, 1, 0)
libxml used : (2, 12, 6)
libxml compiled : (2, 12, 6)
libxslt used : (1, 1, 39)
libxslt compiled : (1, 1, 39)
description: | updated |
description: | updated |
Changed in lxml: | |
status: | Fix Committed → Fix Released |
It's not "incorrect", it just uses a different form of encoding/escaping. The text value is correctly propagated.
But the escaping is unnecessary for UTF-8 and uselessly grows the output data. It should just rely on the normal encoding mechanism.
Fixed in https:/ /github. com/lxml/ lxml/commit/ b8cd0e253f98509 0478c71c8d30c62 9a136a944e
Thanks for the report.