Allow returning std::strings with embedded null characters (why one would want to do this is beyond my understanding)

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4337 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Luigi Ballabio 2003-02-18 17:13:13 +00:00
commit dc309054dd
2 changed files with 3 additions and 3 deletions

View file

@ -20,7 +20,7 @@ double SwigNumber_AsDouble(PyObject* o) {
: double(PyLong_AsLong(o)));
}
PyObject* SwigString_FromString(const std::string& s) {
return PyString_FromString(s.c_str());
return PyString_FromStringAndSize(s.data(),s.size());
}
std::string SwigString_AsString(PyObject* o) {
return std::string(PyString_AsString(o));