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
@applyand replacing them by an explicit call to the class/method. - Using
sixfor some modules that were renamed (e.g.threadis now_thread), as well as some renamed methodsiteritemsis nowitems. - Replacing
raisewith a tuple of two elements with the appropriate call to the exception constructor. - Using
sixfor achieving areraisewith an existing traceback, as the old system (raising a tuple of three elements) cannot be used in Python 3. - I also changed the
requires_extraforteststo 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.