[C++-sig] Creating a python class from c++
James Healey
healeyjames at yahoo.co.uk
Wed Nov 15 20:45:30 CET 2006
It seem to have some thing to do with what's in the
.py file im loading, if i have it empty or do some
thing simple like var = 1, then it loads fine.
I did have:
import MyTest
MyTest()
and call a test function, my c++ code looks like:
BOOST_PYTHON_MODULE( MyTest )
{
boost::python::def( "TestFunc", &TestFunc );
}
And just before I call the exec_file function i have
this...
Py_Initialize();
initMyTest();
--- Stefan Seefeld <seefeld at sympatico.ca> wrote:
> James Healey wrote:
> > PyFile_AsFile returns a ptr to a file object so
> that's
> > working as it should.
> >
> > And how do i check the exception?
> >
> > Do i need to do any thing with the dict that gets
> > passed into exec_file?
>
> No. If the PyFile_AsFile call returns NULL you know
> something is wrong, and an exception is set (i.e.
> PyErr_Occured() returns a non-null pointer to the
> exception object.
>
> However, all that should be dealt with by
> boost.python
> already. Don't you see a C++ exception fly by ?
>
> FWIW, you may want to look at the exec.cpp unit test
> in a boost CVS snapshot. It should test all of the
> above.
>
> HTH,
> Stefan
>
> --
>
> ...ich hab' noch einen Koffer in Berlin...
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>
Send instant messages to your online friends http://uk.messenger.yahoo.com
More information about the Cplusplus-sig
mailing list