[C++-sig] Can't import boost_python module in Mac OS X
David Abrahams
dave at boost-consulting.com
Tue Sep 11 22:02:12 CEST 2007
on Tue Sep 11 2007, Greg Smolyn <greg-AT-smolyn.org> wrote:
>> Really, the only way to debug this is to run gdb on python itself and
>> set a breakpoint in the function that is used to throw exceptions, so
>> you can see what it's actually complaining about.
>>
>
> Ok, I did that, and I get this:
>
> #0 PyErr_Restore (type=0x94e0, value=0x3acd0, traceback=0x0) at
> Python/errors.c:22
> #1 0x002954f2 in PyErr_SetString (exception=0x94e0, string=0x20cf710
> "attribute name must be string") at Python/errors.c:51
> #2 0x02042170 in PyObject_SetAttr (v=0x5b1b0, name=0x5ac00,
> value=0x609940) at Objects/object.c:1128
> #3 0x00793279 in boost::python::objects::function::add_to_namespace ()
> #4 0x0079699f in boost::python::detail::scope_setattr_doc ()
> #5 0x007085a1 in boost::python::detail::def_from_helper<std::string (*)(
> std::string, double), boost::python::detail::def_helper<char [87],
> boost::python::detail::not_specified, boost::python::detail::not_specified,
> boost::python::detail::not_specified> > (name=
> 0x707810 "consensus", fn=@0xbfffd774, helper=@0xbfffd738) at
> /opt/local/include/boost-1_34/boost/python/def.hpp:42
> #6 0x007089ab in boost::python::detail::def_maybe_overloads<std::string (*)(
> std::string, double), char [87]> (name=0x707810 "consensus", fn=0x7075a2
> <consensus(std::string, double)>, a1=@0x7077b8) at
> /opt/local/include/boost-1_34/boost/python/def.hpp:65
> #7 0x007089d4 in boost::python::def<std::string (*)(std::string, double),
> char [87]> (name=0x707810 "consensus", arg1=0x7075a2 <consensus(std::string,
> double)>, arg2=@0x7077b8) at
> /opt/local/include/boost-1_34/boost/python/def.hpp:97
> #8 0x007076fb in init_module_pycov () at /Users/smolyn/school/bio/libcov/src/
> wrappers/python.cpp:23
> [...]
>
> What's interesting is that at frame #2, it does a PyString_Check(name),
> which does a typecheck that name.ob_type == &PyString_Type.
> This, apparently, fails. The interesting part is that in gdb,
> I get name.ob_type == &PyString_Type to be TRUE.
>
> Inspecting name shows it to definitely be a PyString_Type.
> I wish I knew what gives!
It should be possible to set a conditional breakpoint in
PyObject_SetAttr that checks for the particular string you're passing,
so you can trace each step from there.
Good luck,
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com
More information about the Cplusplus-sig
mailing list