Thank you for the reply! As you spotted, I was making an embarrassingly
idiotic typo (due to too much cut and pasting)... it should of course have
been
handle<> h(result);
return object(h);
Once that was fixed, everything worked fine.
I believe this is impossible: Python treats strings as immutable, which
means you can't manipulate them in-place, and there is no C API function
There is apparently one exception to this, which I was utilising:
char* PyString_AsString(PyObject *string) Returns a NUL-terminated
representation of the contents of string. The pointer refers to the
internal buffer of string, not a copy. The data must not be modified in any
way, unless the string was just created using
PyString_FromStringAndSize(NULL, size).
I.e. if you create a string using PyString_FromStringAndSize(0, n), then
you can immediately modify its contents using PyString_AsString. AFAICS
this functionality is (reasonably enough) not wrapped by
boost::python::str, so you have to use the underlying API.
Thanks again for spotting that!
Best wishes,
Mohan
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig