Commit c1a277b7 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 8c562ebb
...@@ -77,10 +77,11 @@ def formToXML(form, prologue=1): ...@@ -77,10 +77,11 @@ def formToXML(form, prologue=1):
delegated_list.sort() delegated_list.sort()
[SubElement(delegated_list_element, delegated) for delegated in delegated_list] [SubElement(delegated_list_element, delegated) for delegated in delegated_list]
if form.unicode_mode: encoding = 'utf-8' if form.unicode_mode else form.stored_encoding
xml = etree.tostring(form_as_xml, encoding='utf-8', xml = etree.tostring(
xml_declaration=True, pretty_print=True) form_as_xml,
else: encoding=encoding,
xml = etree.tostring(form_as_xml, encoding=form.stored_encoding, xml_declaration=True,
xml_declaration=True, pretty_print=True) pretty_print=True,
return bytes2str(xml) )
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