Skip to content

Formulator: repair FormToXML for py2

Jérome Perrin requested to merge fix/form_to_xml_py2 into master

In 1b555dbf (py2/py3: Make Products code compatible with both python2 and python3 (!1751 (merged))., 2024-07-16) we changed the code in a way that on python2 it would first node text to a python2 str and only later convert it to unicode, but setting text to a str during the first step can fail with:

ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

This change to set directly unicode on py2.

At the same time, fix a bug discovered with the test, groups with non-ascii names could not be serialized on py2.

Also remove unnecessary if six.PY3: ret = bytes2str(bytes), bytes2str is no-op on py2

Merge request reports