pr8765-raise-decode-error.patch 833 B

1234567891011121314151617
  1. diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc
  2. index 31d4003..7d69688 100644
  3. --- a/python/google/protobuf/pyext/message.cc
  4. +++ b/python/google/protobuf/pyext/message.cc
  5. @@ -1920,10 +1920,8 @@ static PyObject* MergeFromString(CMessage* self, PyObject* arg) {
  6. // ctx has an explicit limit set (length of string_view), so we have to
  7. // check we ended at that limit.
  8. if (!ctx.EndedAtLimit()) {
  9. - // TODO(jieluo): Raise error and return NULL instead.
  10. - // b/27494216
  11. - PyErr_Warn(nullptr, "Unexpected end-group tag: Not all data was converted");
  12. - return PyLong_FromLong(data.len - ctx.BytesUntilLimit(ptr));
  13. + PyErr_Format(DecodeError_class, "Unexpected end-group tag: Not all data was converted");
  14. + return nullptr;
  15. }
  16. return PyLong_FromLong(data.len);
  17. }