Boost logo

Boost :

Subject: [boost] Preliminary progress on Boost.Python py3k support
From: Haoyu Bai (divinekid_at_[hidden])
Date: 2009-04-01 16:07:52


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk