Problematic error embedding Python using boost::python

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Problematic error embedding Python using boost::python

milosz derezynski
Hello all,

First of all i'd like to say that i don't know much if anything at all about the inner workings of boost::python; however, i am familar with the Python C API. The following problem persists at the moment, leaving me/us (developers on the project) partially stuck.

Our application acts a a scripting host for scripts which access parts of the application's C++ API, exposed via boost::python. Using a typical loading procedure, our app loads scripts, which define a particular class derived from a base class we provide, which the C++ host instantiates in C/C++-space (the scripts only provide the class, do not execute any code beyonc the scope of the class).

Whenever the application starts up, we randomly (sometimes not at all) receive an error like this:

  if state == mpx.PlayStatus.STOPPED:
Traceback (most recent call last):
  File "/usr/share/mpx/scripts/trackinfo/", line 498, in pstate_changed
    if state == mpx.PlayStatus.STOPPED:
TypeError: expected string or Unicode object, NoneType found

However, 'mpx' itself a module, 'state' is variable which positively has a value assigned to it, and 'PlayStatus', 'STOPPED' are defined in C++ using boost python. It seems it it is not an error with the python code itself, as it spuriously appears (only once for the entire session of the application) at various points of execution/with various scripts.

Tracing it back to C++-space didn't come up with any results yet so far either.

Is this a problem in how boost::python wraps classes into Python? So far we're really sure this isn't a problem with our code, but we're not sure where to look further (trying with the plain C API would be immensely tedious at this moment, boost::python is a real timesaver!)

Does anyone know about this issue, or has seen similar?


Milosz Derezynski


The code defining these classes can be found here:

This email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.;198757673;13503038;p?
Boost-langbinding mailing list
[hidden email]