• Arnaud Fontaine's avatar
    py2/py3: Make Products code compatible with both python2 and python3. · 036a541a
    Arnaud Fontaine authored
    Done through various 2to3 fixers (zope.fixers, modernize, future) and also
    contain manual changes. This is a single commit so that we have a clearer
    picture of how code converted with my2to3 should look like.
    
    Except straightforward @implementer decorator 2to3 fixer, only product/ folder
    was considered as the goal was to be able to create an ERP5Site.
    
    * Use @implementer decorator introduced in zope.interface 3.6.0 (2010):
    
      The implements syntax used under Python 2.X does not work under 3.X, since it
      depends on how metaclasses are implemented and this has changed. Instead it
      now supports a decorator syntax (also under Python 2.X).
    
      Applied thanks to 2to3 `zope.fixers` package.
    
    * Use `six.moves` rather than `future` install_aliases() feature because the
      latter use unicode_literals and "wraps" module aliases so that unicode() are
      returned for text rather than str() (Python2 standard library). This notably
      breaks BusinessTemplate code which uses urllib quote() for filesystem paths...
    
    * No more unbound methods in python3 so use six.get_unbound_function().
    
    * dict.(iteritems,iterkeys,itervalues)() => six.\1(dict) thanks to `dict_six`
      2to3 fixer from `modernize`:
      $ python-modernize -w -f dict_six product/
    
    * Manually make sure that dict.{items,values,keys}() returns a real list when
      needed rather than a dict_{items,values,keys} when it is latter modified. By
      default, 2to3 blindly does list(dict.{items,values,keys}()) which is not
      acceptable from performances point of view. With my2to3, this will be possible
      to handle such case automatically.
    036a541a
TrashTool.py 11.5 KB