1. 01 Aug, 2024 5 commits
    • Jérome Perrin's avatar
      fixup! py3: _mysql.string_literal() returns bytes(). · 06d31dbb
      Jérome Perrin authored
      Followup of 94739085.
      06d31dbb
    • Arnaud Fontaine's avatar
      py3: cmp()-based comparison and sorting have been dropped. · dfd6d946
      Arnaud Fontaine authored
      key()-based sorting is now used instead, available since Python 2.4.
      dfd6d946
    • Arnaud Fontaine's avatar
      598ba5fd
    • Jérome Perrin's avatar
      WIP: py3: Fix pylint/SyntaxWarning warnings. · c0fd8ee0
      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>
      c0fd8ee0
    • Jérome Perrin's avatar
      WIP: py2/py3: Make Products code compatible with both python2 and python3. · 37194006
      Jérome Perrin authored
      * Zope API changes:
        + publish() stdin is now BytesIO rather than StringIO.
        + BaseResponse `body` property is now bytes().
      * Python3 API changes:
        + builtin reduce() was removed.
        + 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()).
        + 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.
      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>
      37194006
  2. 31 Jul, 2024 4 commits
  3. 30 Jul, 2024 1 commit
  4. 29 Jul, 2024 4 commits
  5. 25 Jul, 2024 2 commits
  6. 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
  7. 18 Jul, 2024 1 commit
  8. 17 Jul, 2024 2 commits
    • Arnaud Fontaine's avatar
      py2/py3: Fix __import__ fromlist argument. · 73c73960
      Arnaud Fontaine authored
      __import__ `fromlist` argument was wrong. It was working anyway with Python2 but
      not anymore with Python3, raising a `ModuleNotFoundError` exception. According
      to Python `__import__(name, globals, locals, fromlist)` documentation:
      
        When the `name` variable is of the form `package.module`, normally, the
        top-level package (the `name` up till the first dot) is returned, *not* the
        module named by `name`. However, when a non-empty `fromlist` argument is
        given, the module named by `name` is returned.
      
      Thus, the following patterns were wrong:
        * __import__(MODULE_NAME, globals(), locals(), MODULE_NAME)
          => Iterate through each character of MODULE_NAME as fromlist is expected to
             be a list/tuple.
        * __import__(MODULE_NAME, globals(), locals(), [MODULE_NAME])
          => This works but actually tries to import MODULE_NAME object from
             MODULE_NAME module (no error if it cannot).
      
      The goal of such __import__ calls were for __import__ to return the right-end
      module instead of the top-level package. In such case, `fromlist=['']` is the
      way to go as it __import__ does not check if the object exists in the module if
      it's an empty string. However, it is even better and easier to read to use
      importlib.import_module() for that...
      
      Also, add `from __future__ import absolute_import` because python2 tries both
      relative and absolute import (level=-1 __import__ parameter) whereas python3
      does absolute import by default (level=0).
      Co-authored-by: Kazuhiko Shiozaki's avatarKazuhiko SHIOZAKI <kazuhiko@nexedi.com>
      73c73960
    • Nicolas Wavrant's avatar
  9. 15 Jul, 2024 1 commit
    • Jérome Perrin's avatar
      tests: fix DateTime.isPast() under pinDateTime · 78f80ad2
      Jérome Perrin authored
      When under a pinDateTime context, d.isPast() was comparing d with the
      actual current date, not the fake date from the pinned context.
      
      Also, make the methods class methods, so that they can be used as
      external methods in Zelenium tests.
      78f80ad2
  10. 11 Jul, 2024 17 commits
  11. 09 Jul, 2024 1 commit
    • Kazuhiko Shiozaki's avatar
      py2/py3: return None in ZSQLBrain._aq_dynamic() if getObject() because of missing path. · 89725905
      Kazuhiko Shiozaki authored
      in Python 2, _aq_dynamic() returns None without try..except but it raises ValueError in Python 3.
      
      (python 2)
      > /SR/parts/erp5/product/ZSQLCatalog/Extensions/zsqlbrain.py(31)_aq_dynamic()
       31  ->   def _aq_dynamic(self, name):
       32         """Acquire an attribute from a real object.
       33         """
       34         if name.startswith('__') :
       35           return None
       36         return getattr(self.getObject(), name, None)
      ((Pdb)) getattr(self.getObject(), name, None)
      *** ValueError: Unable to getObject from ZSQLBrain if ZSQL Method does not retrieve the `path` column from catalog table.
      ((Pdb)) r
      --Return--
      > /SR/parts/erp5/product/ZSQLCatalog/Extensions/zsqlbrain.py(36)_aq_dynamic()->None # <-- !!!
      Co-authored-by: Jérome Perrin's avatarJérome Perrin <jerome@nexedi.com>
      89725905