From 27028bcb978061a38f2e4c53629a048263f8b7a8 Mon Sep 17 00:00:00 2001 From: "kenton@google.com" Date: Tue, 27 Jul 2010 21:19:59 +0000 Subject: Fix issue 208. --- python/google/protobuf/reflection.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'python/google/protobuf/reflection.py') 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() -- cgit v1.2.3