aboutsummaryrefslogtreecommitdiff
path: root/python/google/protobuf/reflection.py
diff options
context:
space:
mode:
authorkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-07-27 20:45:09 +0000
committerkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-07-27 20:45:09 +0000
commit0c293def6c23cc73b28e0adb55f70b1f47382563 (patch)
tree26615376a8fddec8389f99966ec48c6ebe71e4f8 /python/google/protobuf/reflection.py
parent15b675eea572ed092d5f01148c9ebabf09186972 (diff)
downloadprotobuf-0c293def6c23cc73b28e0adb55f70b1f47382563.tar.gz
protobuf-0c293def6c23cc73b28e0adb55f70b1f47382563.tar.bz2
protobuf-0c293def6c23cc73b28e0adb55f70b1f47382563.zip
Fix issue 207
Diffstat (limited to 'python/google/protobuf/reflection.py')
-rwxr-xr-xpython/google/protobuf/reflection.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/python/google/protobuf/reflection.py b/python/google/protobuf/reflection.py
index 5b238031..13bd8e5e 100755
--- a/python/google/protobuf/reflection.py
+++ b/python/google/protobuf/reflection.py
@@ -943,13 +943,21 @@ def _AddMergeFromMethod(cls):
fields = self._fields
for field, value in msg._fields.iteritems():
- if field.label == LABEL_REPEATED or field.cpp_type == CPPTYPE_MESSAGE:
+ if field.label == LABEL_REPEATED:
field_value = fields.get(field)
if field_value is None:
# Construct a new object to represent this field.
field_value = field._default_constructor(self)
fields[field] = field_value
field_value.MergeFrom(value)
+ elif field.cpp_type == CPPTYPE_MESSAGE:
+ if value._is_present_in_parent:
+ field_value = fields.get(field)
+ if field_value is None:
+ # Construct a new object to represent this field.
+ field_value = field._default_constructor(self)
+ fields[field] = field_value
+ field_value.MergeFrom(value)
else:
self._fields[field] = value
cls.MergeFrom = MergeFrom