aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/google/protobuf/reflection.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/google/protobuf/reflection.py')
-rwxr-xr-xpython/google/protobuf/reflection.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/python/google/protobuf/reflection.py b/python/google/protobuf/reflection.py
index 13bd8e5e..45e5ba88 100755
--- a/python/google/protobuf/reflection.py
+++ b/python/google/protobuf/reflection.py
@@ -384,7 +384,7 @@ def _AddInitMethod(message_descriptor, cls):
copy.MergeFrom(field_value)
self._fields[field] = copy
else:
- self._fields[field] = field_value
+ setattr(self, field_name, field_value)
init.__module__ = None
init.__doc__ = None
@@ -937,6 +937,10 @@ def _AddMergeFromMethod(cls):
CPPTYPE_MESSAGE = _FieldDescriptor.CPPTYPE_MESSAGE
def MergeFrom(self, msg):
+ if not isinstance(msg, cls):
+ raise TypeError(
+ "Parameter to MergeFrom() must be instance of same class.")
+
assert msg is not self
self._Modified()