[C++-sig] boost.python crush
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Fri Jun 25 16:11:43 CEST 2004
Is this under Windows? If yes you have to be very careful how you link. Certain
combinations of DLL's lead to obscure failures like yours. There was a thread
about this recently; should be in the archieve:
http://mail.python.org/pipermail/c++-sig/
Look for "windows", "dll", "debug".
If you are using a different platform post the exact details.
Ralf
--- Max Khesin <MKhesin at liquidnet.com> wrote:
> I have the following sample class exposed via boost.python:
>
> class String
> {
> public:
> String(const std::string& v):m_val(v){}
> bool lessThan(const std::string& other) const{return
> this->m_val<other;}
> bool greaterThan(const std::string& other) const{return
> this->m_val>other;}
> bool equals(const std::string& other) const{return
> this->m_val==other;}
> bool regexMatch(const std::string& other) const{return
> this->m_val==other;}
> bool withinDistance(const std::string& other, int dist) const{return
> distance(this->m_val, other)<=dist;}
> private:
> std::string m_val;
> };
>
>
> BOOST_PYTHON_MODULE(test)
> {
> class_<String>("String", init<const std::string&>())
> .def("lessThan", &String::lessThan)
> .def("greaterThan", &String::greaterThan)
> .def("equals", &String::equals)
> .def("regexMatch", &String::regexMatch)
> .def("withinDistance", &String::withinDistance)
> ;
> }
>
> I am calling this from python:
>
> >> import test
> >> s = test.String('hallo')
> >> s.lessThen('hello') #### <<< CRUSH
>
> the debugger seems to point to an access violation in std::string dtor. I
> palyed around with making the argument a plain std::string (instead of const
> std::string&) and const char* - both of those crush, albeit in a different
> place (also dtors, from the looks of it)
>
> Any idea?
>
> thanks,
>
> max
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are addressed. If
> you have received this email in error please notify the system manager. This
> message contains confidential information and is intended only for the
> individual named. If you are not the named addressee you should not
> disseminate, distribute or copy this e-mail.
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
More information about the Cplusplus-sig
mailing list