aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/google/protobuf/reflection.py
diff options
context:
space:
mode:
authorGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-07-27 21:19:59 +0000
committerGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-07-27 21:19:59 +0000
commit27028bcb978061a38f2e4c53629a048263f8b7a8 (patch)
tree7d7ca3b867ebcb9b13c3a7cf973237a2fe1d5646 /python/google/protobuf/reflection.py
parent0c293def6c23cc73b28e0adb55f70b1f47382563 (diff)
Fix issue 208.
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()