1. 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
  2. 18 Jul, 2024 1 commit
  3. 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
  4. 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
  5. 11 Jul, 2024 17 commits
  6. 09 Jul, 2024 11 commits
  7. 07 Jul, 2024 1 commit
  8. 06 Jul, 2024 2 commits
  9. 05 Jul, 2024 3 commits