Skip to content

Fix remaining business template XML differences on py3

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

This addresses all the remaining business template differences on py3, so that the XML representation of all ERP5 business templates currently covered by coding style tests are the same on py2 and py3.

The remaining problems were:

  • only persistent_id of direct reference was <bytes>, indirect references were often still <string>.
  • some small low-level differences, such as empty object states or re flags
  • the remaining cases of <unicode>, which no longer exist in py2. There were different cases:
    • for cases where a str would be OK on py2, the XML was changed directly to use <string> instead of <unicode>.
    • for cases where switching to a str would change the behavior, or cases where it would still be exported as <unicode>, adjust business template to special case the objects. This was the case for title of page templates, or to MailTemplates that we now export as a separate file, as a way to keep using an unicode for _text.
    • there were also a few cases of <unicode> in some unknown/obsolete _cached_mime on some images, which were handled by removing these obsolete attributes from the objects and re-exporting them. There was also <unicode> in PDF Template, but since PDF Template no longer works these days, the template was removed.

This also addresses a potential problem from 699a2836 (XMLExportImport: export business templates with pickle protocol 3., 2025-10-16) and 2263917a (*: re-export business templates, 2025-10-16), which caused some document properties, typically File.data to become zodbpickle.binary instances on py2 - and zodbpickle.binary are not allowed in restricted python. To prevent some unexpected unauthorized errors when such an object is accessed from restricted python, we allow access to this class, it is just a str subclass.

Edited by Jérome Perrin

Merge request reports