[C++-sig] Problems instantiating class Boost Python class

David Abrahams dave at boost-consulting.com
Wed Jun 13 04:35:49 CEST 2007


on Mon Jun 11 2007, Phil <phil.beadling-AT-homechoice.co.uk> wrote:

> Hi,
>
> I'm a newbie having some problems instantiating a class written in C++ 
> in Python using Boost.Python.
>
> I can get a very simple example working when I expose a function outside 
> of a class, that returns a string, but the below fails as shown, despite 
> building.  The enum in the same library however works fine.
>
> I've googled the error returned from Python and I get zero hits - has 
> anyone get any idea what I'm doing wrong?
>
> I'm using Python 2.5, GCC 4.0.1 and Boost 1.33 on Mac OS X 10.4.9.  I 
> don't think it matters but I'm building the solution as a dynamic C++ 
> bsd library in XCode and the changing the Mac OS X .dylib extention to 
> .so as is required by Python.  This all works for simpler examples and 
> the enum in this example.
>
> Error: TypeError: __init__() should return None, not 'NoneType'

Phil,

First, I suggest you take your question to a more subject-specific
mailing list: http://www.boost.org/more/mailing_lists.htm#cplussig

I have no clue what could be going wrong here; I've never seen
that problem.

My only suggestion to you is to further reduce your test case to the
absolute minimal example that reproduces the behavior.  That almost
always makes the problem obvious, or at least easily diagnosed.  Your
example is small, but surely not minimal yet.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

The Astoria Seminar ==> http://www.astoriaseminar.com




More information about the Cplusplus-sig mailing list