[C++-sig] Re: Tedious Newbie Question

David Abrahams dave at boost-consulting.com
Tue Jun 8 14:05:18 CEST 2004


Gareth Simpson <g.simpson at zoo-tech.com> writes:

>> 
>> > I am trying to use Boost.Python to embed a Python library 
>> into my C++
>> > application.  The library in question uses unicode strings 
>> internally and I
>> > can't for the life of me work out how to get them out and 
>> into my C++.
>> > Google is largely silent on the matter.
>> >
>> > I have no problem using extract<> to get a python string 
>> into a std::string
>> > but trying the same thing with unicode python strings and 
>> std::wstrings
>> > throws an exception.
>> >
>> > Clearly I'm going about it the wrong way - what should I be doing?
>> 
>> Probably you need to be using a newer version of Boost; we've
>> supported wstring conversions since Boost 1.31.0.
>
>
> That's the version of boost I have.
>
> It looks like it's trying to delete something it shouldn't (access
> violation) somewhere in the bowels of the STL / boost::python

Oh, in that case it's probably something in your own code that's
causing the crash.

> Interestingly if I go up the call stack to where the extract<std::wstring>()
> is being called, the unicode string has actually arrived.

;-) That should tell you something.

>> 
>> But we don't support Py_Finalize(); see
>> http://www.boost.org/libs/python/todo.html#pyfinalize-safety
>
> Ah, what should I do instead?

Nothing; just don't call it.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com





More information about the Cplusplus-sig mailing list