[C++-sig] none
David Abrahams
dave at boost-consulting.com
Thu Apr 20 01:25:26 CEST 2006
Hi Matthew,
It's better to post these things to the C++-sig:
http://www.boost.org/more/mailing_lists.htm#cplussig
Matthew Giger <mgiger at earthbrowser.com> writes:
> Just thought I'd pass along a fix for a crashing bug to the
> builtin_converters.cpp code:
>
> Change:
>
> std::wstring result(::PyObject_Length(intermediate), L' ');
> int err = PyUnicode_AsWideChar(
> (PyUnicodeObject *)intermediate
> , result.size() ? &result[0] : 0
> , result.size());
>
> if (err == -1)
> throw_error_already_set();
>
>
> To:
>
> std::wstring result;
> int len = ::PyObject_Length(intermediate);
> if(len > 0)
> {
> result.resize(len, L' ');
> int err = PyUnicode_AsWideChar(
> (PyUnicodeObject *)intermediate
> , result.size() ? &result[0] : 0
> , result.size());
>
> if (err == -1)
> throw_error_already_set();
> }
>
Can you explain why this is necessary and what causes the crash you're
reporting?
Also, can you submit a minimal failing testcase? Normally I don't
make fixes withouut an example I can check in as a regression test so
that the fix never gets undone.
> Thanks for writing a great library.
You're welcome.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list