My Experience Porting to CPython 3

My Experience Porting to CPython 3

I was trying to port our C++ app to python 3, but am sadly not having much luck. I use Tools/freeze/freeze.py to embed the .py sources of the python lib into the application, and also build as many C modules into libpython as possible using Modules/Setup.local.

After porting PyString_AsString() calls to PyBytes_AsString(), and updating a few build scripts to use the new print function, I spent a ton of time debugging lib python trying to figure out why the frozen codecs.py isn’t importing. The marshal module is demarshaling “encodings” and “zipimport” correctly, but fails on the code object for codecs.py. I still can’t figure it out.

So now I just have a bunch of #ifdef statements for the new C++ code and a lot of new files added to my project. Disappointing.

Is it considered foolish to try to get python 3 working with our app? It would appear to be a good idea to get the new interpreter in before we release in a couple of months and our users start writing code for it. But, I’ve read plenty of stuff that says it’s a bad idea right now. Good grief!