Closed
Description
The document of Python3 says:
wchar_t* PyUnicode_AsWideCharString(PyObject *unicode, Py_ssize_t *size)
Returns a buffer allocated by PyMem_Alloc() (use PyMem_Free() to free it) on success.
and in cast.h of pybind11:
template <> class type_casterstd::wstring
#if PY_MAJOR_VERSION >= 3
buffer = PyUnicode_AsWideCharString(load_src.ptr(), &length);
#else
...
#endif
if (!buffer) { PyErr_Clear(); return false; }
value = std::wstring(buffer, (size_t) length);
success = true;
return true;
Why we don't need to call PyMem_Free to free the buffer in this case?
Metadata
Metadata
Assignees
Labels
No labels