Preliminary progress on Boost.Python py3k support

Hi, I did some preliminary work on BPL py3k support in these days. With Troy's help we have a py3k SVN tree in sandbox now, which is branched from trunk. I also tried to compile BPL with Python 3, and by following the error report of the compiler, I did some patch - now we have 14 .cpp files out of 28 in total can be compiled. The patch is committed, you can see it here: [2]. Please point me out if the code has something don't conform to Boost coding policy. There's also something interesting, maybe a bug I caught, for example: (Search the changeset to see details) 39 // XXX(bhy) Potentional memory leak here since PyObject_GetAttrString returns a new reference 40 // const char *mod = PyString_AsString(PyObject_GetAttrString( self_, const_cast<char*>("__module__"))); 41 PyObject *mod = PyObject_GetAttrString( self_, "__module__"); Also I found some potential problem with Py_ssize_t, I will take this as a chance to fix them. The biggest problem I see still is the "Text Vs. Data Instead Of Unicode Vs. 8-bit" in py3k. As we discussed and the suggestion by Niall [3], we have a clear solution for this and I will work towarding this. The other changes in py3k such as PyObject_HEAD change, int type removal and unbound method removal also affected Boost.Python's code, but they don't require logical change of BPL code and easy to handle. Hopefully in the end of this summer, we will have a Boost.Python library with Python 3 support! Thanks again for many people's help! References: [1] https://svn.boost.org/trac/boost/browser/sandbox-branches [2] https://svn.boost.org/trac/boost/changeset/52118 [3] “Nabble - Python - c++-sig - Some thoughts on py3k support,” http://www.nabble.com/Some-thoughts-on-py3k-support-td22564813.html. -- Haoyu Bai

on Wed Apr 01 2009, Haoyu Bai <divinekid-AT-gmail.com> wrote:
Hi,
I did some preliminary work on BPL py3k support in these days.
With Troy's help we have a py3k SVN tree in sandbox now, which is branched from trunk. I also tried to compile BPL with Python 3, and by following the error report of the compiler, I did some patch - now we have 14 .cpp files out of 28 in total can be compiled. The patch is committed, you can see it here: [2].
Haoyu, Just FYI, the existing codebase was written to support MSVC6 and 7.0, and as such has lots of hacks and/or inferior idioms. I have basically dropped support for those compilers, so feel free to replace that code with more modern stuff as needed.
Please point me out if the code has something don't conform to Boost coding policy. There's also something interesting, maybe a bug I caught, for example: (Search the changeset to see details)
39 // XXX(bhy) Potentional memory leak here since PyObject_GetAttrString returns a new reference 40 // const char *mod = PyString_AsString(PyObject_GetAttrString( self_, const_cast<char*>("__module__"))); 41 PyObject *mod = PyObject_GetAttrString( self_, "__module__");
Yes, looks like a bug, thanks.
Also I found some potential problem with Py_ssize_t, I will take this as a chance to fix them.
Please do.
The biggest problem I see still is the "Text Vs. Data Instead Of Unicode Vs. 8-bit" in py3k.
I think it makes sense to convert char const* to string in py3k...
As we discussed and the suggestion by Niall [3], we have a clear solution for this
...I guess I'd better be more careful to keep up with that mailing list! I haven't had a chance to read Niall's post yet.
and I will work towarding this. The other changes in py3k such as PyObject_HEAD change, int type removal and unbound method removal also affected Boost.Python's code, but they don't require logical change of BPL code and easy to handle.
Hopefully in the end of this summer, we will have a Boost.Python library with Python 3 support!
Awesome; thanks for your efforts! -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (2)
-
David Abrahams
-
Haoyu Bai