• Carlos Ramos Carreño's avatar
    Allow importing from Python 3. · 446cc613
    Carlos Ramos Carreño authored
    Do the necessary changes so that the main module can be imported inside
    a Python 3 project without errors.
    Note that the project will still not work in Python 3, but a project
    that imports NEO unconditionally and does not use it in Python 3, such
    as wendelin.core, won't have problems.
    
    The changes here are mostly:
      - Replacing old-style excepts (`except Exception, e:`) with the new
      syntax (`except Exception as e:`), compatible with both Python 2 and
      3.
      - Removing calls to `@apply` and replacing them by an explicit call
      to the class/method.
      - Using `six` for some modules that were renamed (e.g. `thread` is
      now `_thread`), as well as some renamed methods `iteritems` is now
      `items`.
      - Replacing `raise` with a tuple of two elements with the appropriate
      call to the exception constructor.
      - Using `six` for achieving a `reraise` with an existing traceback,
      as the old system (raising a tuple of three elements) cannot be used
      in Python 3.
      - I also changed the `requires_extra` for `tests` to include all other
      extras as intended, because the way it was being done did not work
      for me.
    
    The changes are intended to be as surgical and non-controversial as
    possible, in order to facilitate review and acceptance.
    I can try to achieve full compatibility with Python 3 in future MRs, if
    that is desired.
    I ran the unittests locally in Python 2 and they seemed to work.
    446cc613
config.py 6.45 KB