[C++-sig] Contributing an embedding example (after a bugfix ;)

David Abrahams dave at boost-consulting.com
Fri Nov 22 19:58:11 CET 2002


Dirk Gerrits <dirk at gerrits.homeip.net> writes:

> After receiving a lot of help in another thread (thanks!) I was able
> to get my little Boost.Python program using embedding to compile and
> run. It works great! But upon deinitialization with Py_Finalize(), I
> get an error:
>
> Fatal Python error: PyThreadState_Get: no current thread
>
> I don't really know what is causing this, so I am asking for your help
> again. :)

The problem is that Boost.Python doesn't yet support PyFinalize(). It
keeps some PyObject references alive in global data structures, and
when those go out of scope after interpreter finalization, Python
crashes. It's a fairly simple project to fix this, though it will take
some work. Patches welcome.

> After having fixed this though, I'd be willing to contribute this as
> an example for Boost.Python, if there is interest. I thought it was a
> pretty neat technique myself. ;)

Please do; It's a nice example!

> Before that, I'd need to Boostify the code a bit though, and I am
> wondering if all of it is necessary. For example, BaseWrap seems a bit
> superfluous since I'm only using Base's polymorphism from the C++
> side. Any comments on this?

That's exactly what it's for. You if you want to override the C++
virtual function f() in Python, you need the dispatching override in
BaseWrap.

-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list