fix bug in numbuf serialization (#296)

This commit is contained in:
Philipp Moritz 2017-02-17 23:35:41 -08:00 committed by Robert Nishihara
parent a0dd3a44c0
commit 9973a6e37c

View file

@ -98,13 +98,14 @@ Status append(PyObject* elem, SequenceBuilder& builder, std::vector<PyObject*>&
Py_ssize_t size;
#if PY_MAJOR_VERSION >= 3
char* data = PyUnicode_AsUTF8AndSize(elem, &size);
Status s = builder.AppendString(data, size);
#else
PyObject* str = PyUnicode_AsUTF8String(elem);
char* data = PyString_AS_STRING(str);
size = PyString_GET_SIZE(str);
Status s = builder.AppendString(data, size);
Py_XDECREF(str);
#endif
Status s = builder.AppendString(data, size);
RETURN_NOT_OK(s);
} else if (PyList_Check(elem)) {
builder.AppendList(PyList_Size(elem));