|
|
@ -1427,8 +1427,7 @@ bool CheckHasPresence(const FieldDescriptor* field_descriptor, bool in_oneof) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (field_descriptor->containing_oneof() == NULL && |
|
|
|
if (!field_descriptor->has_presence()) { |
|
|
|
!field_descriptor->is_singular_with_presence()) { |
|
|
|
|
|
|
|
PyErr_Format(PyExc_ValueError, |
|
|
|
PyErr_Format(PyExc_ValueError, |
|
|
|
"Can't test non-optional, non-submessage field \"%s.%s\" for " |
|
|
|
"Can't test non-optional, non-submessage field \"%s.%s\" for " |
|
|
|
"presence in proto3.", |
|
|
|
"presence in proto3.", |
|
|
@ -2171,7 +2170,8 @@ static PyObject* RichCompare(CMessage* self, PyObject* other, int opid) { |
|
|
|
// If other is not a message, it cannot be equal.
|
|
|
|
// If other is not a message, it cannot be equal.
|
|
|
|
if (!PyObject_TypeCheck(other, CMessage_Type)) { |
|
|
|
if (!PyObject_TypeCheck(other, CMessage_Type)) { |
|
|
|
equals = false; |
|
|
|
equals = false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
// Otherwise, we have a CMessage whose message we can inspect.
|
|
|
|
const google::protobuf::Message* other_message = |
|
|
|
const google::protobuf::Message* other_message = |
|
|
|
reinterpret_cast<CMessage*>(other)->message; |
|
|
|
reinterpret_cast<CMessage*>(other)->message; |
|
|
|
// If messages don't have the same descriptors, they are not equal.
|
|
|
|
// If messages don't have the same descriptors, they are not equal.
|
|
|
@ -2180,11 +2180,12 @@ static PyObject* RichCompare(CMessage* self, PyObject* other, int opid) { |
|
|
|
equals = false; |
|
|
|
equals = false; |
|
|
|
} |
|
|
|
} |
|
|
|
// Check the message contents.
|
|
|
|
// Check the message contents.
|
|
|
|
if (equals && !google::protobuf::util::MessageDifferencer::Equals( |
|
|
|
if (equals && |
|
|
|
*self->message, |
|
|
|
!google::protobuf::util::MessageDifferencer::Equals( |
|
|
|
*reinterpret_cast<CMessage*>(other)->message)) { |
|
|
|
*self->message, *reinterpret_cast<CMessage*>(other)->message)) { |
|
|
|
equals = false; |
|
|
|
equals = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (equals ^ (opid == Py_EQ)) { |
|
|
|
if (equals ^ (opid == Py_EQ)) { |
|
|
|
Py_RETURN_FALSE; |
|
|
|
Py_RETURN_FALSE; |
|
|
|