1. 30 Aug, 2024 9 commits
    • Arnaud Fontaine's avatar
      py3: cmp()-based comparison and sorting have been dropped. · 425f8cb3
      Arnaud Fontaine authored
      key()-based sorting is now used instead, available since Python 2.4.
      425f8cb3
    • Jérome Perrin's avatar
      py3: Fix pylint/SyntaxWarning warnings. · e20a80fa
      Jérome Perrin authored
      Also, remove `if True/1/False/0` statement raising pylint warnings.
      Co-authored-by: Arnaud Fontaine's avatarArnaud Fontaine <arnaud.fontaine@nexedi.com>
      e20a80fa
    • Jérome Perrin's avatar
      py2/py3: Make Products code compatible with both python2 and python3. · 8c875ccc
      Jérome Perrin authored
      * Zope API changes:
        + publish() stdin is now BytesIO rather than StringIO.
        + HTTPResponse `body` property is now bytes().
        + OFS.Image.File file parameter is bytes().
        + zope.interface implements() is now @implementer decorator.
        + Python standard logging module recommended instead of zLOG.
      * Python3 API changes:
        + builtin reduce() was removed.
        + urlnorm is now available.
        + Use BytesIO rather than StringIO to follow py3 API.
        + hmac.new() requires digestmod argument from Python 3.8.
        + Use six.moves library to handle moved objects from py2 to py3.
        + `modernize -f xrange_six` then slightly adjusted manually to just use range
           where it does not make a significant difference (for example in test).
        + base64.b64encode() now expects bytes().
        + UserDict() interface changed:
          - New parameter in update() and pop().
          - `failobj` setdefault parameter renamed to `default`.
        + ensure_list() on dict.{values,items}() and list(dict) for dict.keys() when
          we really need a list and not an iterable (Python3).
          - Add ensure_list() to RestrictedPython safe_builtins as it's very common usage.
        + Make dict iteration works on both version of Python.
          - Use six.iter{items,values,keys}().
          - has_key() has been removed.
          - Make sure that dict.{items,values,keys}() returns a real list when
          modified (ensure_list()).
        + Comparisons between int and NoneType raises TypeError.
        + No more unbound methods in python3 so use six.get_unbound_function().
        + Exceptions:
          - No longer behave as sequences. Using `args` attribute instead.
          - When an exception has been assigned using `as target`, it is cleared at
            the end of the except clause.
        + file: py2 was returning `str` upon reading, now it returns text strings.
          Also, opening mode is text strings by default.
        + Data strings are bytes().
          - Replace str() by bytes().
        + iterators no longer have next() method, instead there is next() builtin.
        + New ConnectionError exception so rename existing one to not clash.
        + Integer division is now with //.
        + __nonzero__ is now __bool__.
        + apply() does not exist anymore.
        + Deprecated threading.Thread isAlive() has been removed.
        + im_func replaced by __func__.
        + Use six.with_metaclass() to define metaclass in a cross-compatible way with py2 and py3.
      Co-Authored-by: Kazuhiko Shiozaki's avatarKazuhiko SHIOZAKI <kazuhiko@nexedi.com>
        Arnaud Fontaine <arnaud.fontaine@nexedi.com>
        Carlos Ramos Carreño <carlos.ramos@nexedi.com>
        Emmeline Vouriot <emmeline.vouriot@nexedi.com>
      8c875ccc
    • Jérome Perrin's avatar
    • Jérome Perrin's avatar
      base/conversion: setContentType before converting to base format · 3f1f23f6
      Jérome Perrin authored
      some conversion (TextDocument) depend on the content type, so it's
      necessary to first update the content type before trying to convert to
      base format
      3f1f23f6
    • Arnaud Fontaine's avatar
      Remove unused code. · a797782a
      Arnaud Fontaine authored
      a797782a
    • Arnaud Fontaine's avatar
      4b513abc
    • Arnaud Fontaine's avatar
      fixup! BusinessTemplate,XMLExportImport: support python3 · d86217b6
      Arnaud Fontaine authored
      syncml: ERP5Conduit can expect that xml_mapping method returns str(). It was
      using bytes(), but this seems wrong now.
      d86217b6
    • Arnaud Fontaine's avatar
      py3: PortalTransforms: sgmllib removed from standard library in favor of html.parser.HTMLParser. · ae8085d2
      Arnaud Fontaine authored
      Use scrubHTML() from safe_html module instead.
      ae8085d2
  2. 28 Aug, 2024 1 commit
  3. 27 Aug, 2024 1 commit
  4. 26 Aug, 2024 4 commits
  5. 16 Aug, 2024 1 commit
  6. 14 Aug, 2024 1 commit
  7. 13 Aug, 2024 1 commit
  8. 12 Aug, 2024 2 commits
  9. 07 Aug, 2024 2 commits
  10. 06 Aug, 2024 1 commit
  11. 02 Aug, 2024 2 commits
  12. 01 Aug, 2024 4 commits
  13. 30 Jul, 2024 1 commit
  14. 29 Jul, 2024 4 commits
  15. 25 Jul, 2024 2 commits
  16. 23 Jul, 2024 2 commits
    • Rafael Monnerat's avatar
      ERP5Type: Include OFSFolder2._cleanup method · 6e6eb5f0
      Rafael Monnerat authored
        This aims to add compatibility with BTreeFolder2 API, even it is not
        required. Since some checkConsistency may call self._cleanup() regardless
        expecting that the folder is a [H]BTreeFolder2 always.
      
        This was detected when a post upgrade constrant was included to
        portal_categories
      6e6eb5f0
    • Jérome Perrin's avatar
      core: handle price 0 or None in Inventory API · 2c525e57
      Jérome Perrin authored
      The methods used in indexing did not make a difference between the case
      where the price is None (ie. price is not set) or where the price is
      set to 0 - in both cases this was saved as NULL in stock.total_price
      column. This is incorrect, we need to keep the distinction between
      these two cases also for inventory calculation.
      We had some places where we select IFNULL(stock.total_price, 0) to work
      around this, we don't plan to change the existing ones for now, but
      while discussing on !1974
      we concluded that a newly idenfified case of a problem consequence of
      these NULL should be handled by fixing the indexation. To benefit from
      the fix, impacted instances will have to reindex documents present in
      the stock table with stock.total_price is null.
      2c525e57
  17. 21 Jul, 2024 2 commits
    • Jérome Perrin's avatar
      XMLExportImport: correctly export booleans as bool on py2 · d285a180
      Jérome Perrin authored
      The ad-hoc handling of boolean in protocol 1 was not implemented
      correctly and they were serialized as integers (0 for False and 1 for
      True), this fixes the export code and re-export everything
      d285a180
    • 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