aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/google/protobuf/internal/containers.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/google/protobuf/internal/containers.py')
-rwxr-xr-xpython/google/protobuf/internal/containers.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/python/google/protobuf/internal/containers.py b/python/google/protobuf/internal/containers.py
index 97cdd848..ce46d08c 100755
--- a/python/google/protobuf/internal/containers.py
+++ b/python/google/protobuf/internal/containers.py
@@ -594,7 +594,11 @@ class MessageMap(MutableMapping):
def MergeFrom(self, other):
for key in other:
- self[key].MergeFrom(other[key])
+ # According to documentation: "When parsing from the wire or when merging,
+ # if there are duplicate map keys the last key seen is used".
+ if key in self:
+ del self[key]
+ self[key].CopyFrom(other[key])
# self._message_listener.Modified() not required here, because
# mutations to submessages already propagate.