[C++-sig] Creating a python class from c++
Stefan Seefeld
seefeld at sympatico.ca
Tue Nov 21 21:18:03 CET 2006
James Healey wrote:
> Im trying to call a python function which is not in a
> class:
>
> exec_file("Data\\Script\\Editor.py", global, global);
>
> boost::python::object func = global["OnClick"];
> func();
>
> But it's falling over when I call the object, global
> returns a valid object and if i look at func in the
> debugger it says it's a function.
>
> It falls over when calling:
...what ?
> // This conversion *must not* be done in the same
> expression as
> // the call, because, in the special case where
> the result is a
> // reference a Python object which was created by
> converting a C++
> // argument for passing to PyEval_CallFunction,
> its reference
> // count will be 2 until the end of the full
> expression containing
> // the conversion, and that interferes with
> dangling
> // pointer/reference detection.
> converter::return_from_python<R> converter;
>
> The ref count of func is 2 is that helps.
Sorry, I don't see any call here. Further, if you really expect anybody to help
you please provide a minimal self-contained test case that allows others to
reproduce the problem. Not to mention that you didn't tell us what platform you
are working on, what toolchain, etc.
Regards,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list