[C++-sig] Wrapping pointers
Dominic Sacré
dominic.sacre at gmx.de
Wed Apr 5 21:05:32 CEST 2006
Hi,
I'm having trouble exporting C++ pointers to Python. My code looks like
this:
class A
{
A *p;
...
};
BOOST_PYTHON_MODULE(test)
{
class_<A>("A", init<>())
.def_readonly("p", &A::p)
...
;
}
Now every time I try to access A::p from Python I get this error:
TypeError: No to_python (by-value) converter found for C++ type: A*
I searched the list archives and found a message about the same issue,
where the only suggestion was to use
.def_readonly("p", make_getter(&A::p, return_internal_reference<1>()))
instead, but this doesn't help either. On the contrary, this causes a
segfault every time I use A::p (although p points to a valid object, at
least in C++).
So what should I do to access this pointer from Python?
Thanks,
Dominic
More information about the Cplusplus-sig
mailing list