[C++-sig] Preliminary progress on Boost.Python py3k support
dave at boostpro.com
Wed Apr 8 17:08:20 CEST 2009
on Wed Apr 01 2009, Haoyu Bai <divinekid-AT-gmail.com> wrote:
> 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: .
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.
> 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 , 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!
More information about the Cplusplus-sig