Commit 11d907d7 authored by Jérome Perrin's avatar Jérome Perrin

Formulator: fix FormToXML with a form encoding on py3

The test from 6316d9bb (Formulator: test form serialization with non
ascii elements, 2024-10-24) revealed that form with an encoding other
than UTF-8 are not supported.
parent 691ead7a
Pipeline #38016 failed with stage
in 0 seconds
......@@ -77,10 +77,11 @@ def formToXML(form, prologue=1):
delegated_list.sort()
[SubElement(delegated_list_element, delegated) for delegated in delegated_list]
if form.unicode_mode:
xml = etree.tostring(form_as_xml, encoding='utf-8',
xml_declaration=True, pretty_print=True)
else:
xml = etree.tostring(form_as_xml, encoding=form.stored_encoding,
xml_declaration=True, pretty_print=True)
return bytes2str(xml)
encoding = 'utf-8' if form.unicode_mode else form.stored_encoding
xml = etree.tostring(
form_as_xml,
encoding=encoding,
xml_declaration=True,
pretty_print=True,
)
return bytes2str(xml, encoding=encoding)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment