[C++-sig] Re: what happened with this std::string parameter in boost.python

kalin kalin.eh at gmail.com
Sun Apr 3 10:52:15 CEST 2005


David Abrahams wrote:
> Donnie Leen wrote:
> 
>>I made a program embedding boost.python, writting a module as following:
>>
>>void write( std::string s )
>>{
>>	// do nothing
>>}
>>BOOST_PYTHON_MODULE(mym)
>>{
>>	def( "write", &write );
>>}
>>
>>
>>I run the python code:
>>import mym
>>s = 'hello'
>>mym.write(s)
>>
>>it runs ok, but if i run the python code as following:
>>import mym
>>s = int.__doc__
>>mym.write(s)
>>
>>it crashed
> 
> 
> What do you mean by "crashed?"  Are you sure it didn't throw an
> exception that was never caught?
> 
> 

I had this problem earlier. It would just access violate, as though the
string had a bad buffer pointer. I didn't look into it too much and
changed it to const char*'s so I could just get things working.

Although now, when I change it back to test, it doesn't crash anymore. :(

FWIW

kalin




More information about the Cplusplus-sig mailing list