• Jérome Perrin's avatar
    BusinessTemplate,XMLExportImport: support python3 · 4483f759
    Jérome Perrin authored
    With these changes, we are able to install py2 business templates on py3,
    but export is slightly different, because we already export using pickle
    protocol 3 on py3.
    
    To be able to install py2 business templates, we included heuristics to
    guess the str or bytes from business template XML: oids are bytes and
    also some strings that do not decode to UTF-8, so that we can install
    python2 business templates on py3.
    
    When exporting business templates, we need to build a list of referenced
    persistent objects to export them separately in the XML, this is is done
    using Unpickler.noload, in a way which does not support pickle protocol
    1 on py3 (the persistent ids are None and the assertion in
    https://github.com/zopefoundation/ZODB/blob/d698507bb89eeb38c6e655199bc9f54c909dbf4d/src/ZODB/serialize.py#L669
    fails), so we need to use pickle protocol 3 on py3.
    
    In the future, we might switch to exporting on protocol 3 on py2 as well
    so that we have stable output on both py2 and py3, or maybe we'll do
    this only when we stop supporting py2.
    4483f759
testBusinessTemplateTwoFileExport.py 48.7 KB