I'm getting this error when calling gRPC function:
TypeError: Parameter to MergeFrom() must be instance of same class: expected common_pb2.NullableString got common_pb2.NullableString.
This happens only in python 3.6.8 on RHEL 6 machine. The call passes in windows / linux with various pythons.
I have debugged this issue and found that the marked line failed (MergeFrom)
copy = field._default_constructor(self)
new_val = field_value
if isinstance(field_value, dict):
new_val = field.message_type._concrete_class(**field_value)
try:
copy.MergeFrom(new_val) # This line fails when calling MergeFrom function
except TypeError:
_ReraiseTypeErrorWithFieldName(message_descriptor.name, field_name)
def MergeFrom(self, msg):
if not isinstance(msg, cls):
raise TypeError(
'Parameter to MergeFrom() must be instance of same class: '
'expected %s got %s.' % (_FullyQualifiedClassName(cls),
_FullyQualifiedClassName(msg.__class__)))
When I print the type of new_val and copy variables, I get the same answer but if comparing them I get a false response.
print(type(new_val))
<class 'common_pb2.NullableString'>
print(type(copy))
<class 'common_pb2.NullableString'>
print(type(copy) == type(new_val))
False
What can be the problem?
These are the versions of protobut and grpcio I'm using:
protobuf==3.19.4 grpcio==1.43.0
Many thanks!