Allow importing from Python 3.
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
- 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 methodsiteritems
is nowitems
. - Replacing
raise
with a tuple of two elements with the appropriate call to the exception constructor. - Using
six
for achieving areraise
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
fortests
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.