|
|
|
@ -1927,9 +1927,8 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static PyObject* MergeFromString(CMessage* self, PyObject* arg) { |
|
|
|
|
const void* data; |
|
|
|
|
Py_ssize_t data_length; |
|
|
|
|
if (PyObject_AsReadBuffer(arg, &data, &data_length) < 0) { |
|
|
|
|
Py_buffer data; |
|
|
|
|
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) < 0) { |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1942,7 +1941,8 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) { |
|
|
|
|
const char* ptr; |
|
|
|
|
internal::ParseContext ctx( |
|
|
|
|
depth, false, &ptr, |
|
|
|
|
StringPiece(static_cast<const char*>(data), data_length)); |
|
|
|
|
StringPiece(static_cast<const char*>(data.buf), data.len)); |
|
|
|
|
PyBuffer_Release(&data); |
|
|
|
|
ctx.data().pool = factory->pool->pool; |
|
|
|
|
ctx.data().factory = factory->message_factory; |
|
|
|
|
|
|
|
|
@ -1968,9 +1968,9 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) { |
|
|
|
|
// TODO(jieluo): Raise error and return NULL instead.
|
|
|
|
|
// b/27494216
|
|
|
|
|
PyErr_Warn(nullptr, "Unexpected end-group tag: Not all data was converted"); |
|
|
|
|
return PyInt_FromLong(data_length - ctx.BytesUntilLimit(ptr)); |
|
|
|
|
return PyInt_FromLong(data.len - ctx.BytesUntilLimit(ptr)); |
|
|
|
|
} |
|
|
|
|
return PyInt_FromLong(data_length); |
|
|
|
|
return PyInt_FromLong(data.len); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static PyObject* ParseFromString(CMessage* self, PyObject* arg) { |
|
|
|
|