Ok I finished src/Base already.... I'll resume the changes here (this is mostly for myself for further reference)https://github.com/yorikvanhavre/FreeCA ... ccc4d5a770
Don't try to use that branch, because compilation will fail (the module generation templates are already updated, but the implementations of each modules not yet, so the build will fail right after Base). This is mostly for who is curious to look. So far it compiles OK with both py2 and py3.
The major changes:
- If using py3, you need minimum 3.3 (otherwise there are some useful unicode<->UTF8 functions not available yet).
- Python3 doesn't have Int and Long anymore. Everything is Long. This is safe to use in py2 too (in python, it is still called int, mind you, but it's a long).
- By far the most important change: All python strings are now unicode. So all strings-related methods are gone. Fortunately since shoogen and werner already made a great job at spreading the use of UTF8 everywhere, this doesn't give major problems, it even simplifies (no more of that question to use Latin1 or Utf8)
- PyObject->ob_type doesn't exist anymore, use Py_TYPE(PyObject)
- Class definition (PyTypeObject) has changed a lot:
- different way to initialize it (PyVarObject_HEAD_INIT instead of PyObject_HEAD_INIT)
- tp_getattr and tp_setattr slots are being deprecated. Use tp_getattro and tp_setattro instead (they take a PyObject instead of a char*)
- several numeric handlers have been removed: divide (everything is remainder now), long (everything is long now, but the handler to keep is int
), coerce, oct and hex.
- Inside python code:
- print "something" becomes print("something"), works in py2 too
- print("something","something else") doesn't work in py2 unless "from __future__ import print_function"
- for key, value in dict.iteritems() becomes for key,value in dict.items(), works in py2 too
- except Error,message becomes except Error(message) works in py2 too
- import submodule becomes from . import submodule