Skip to content

Commit 533fbbb

Browse files
anandoleecopybara-github
authored andcommitted
Add tuple support to set Struct
fixes #13205 PiperOrigin-RevId: 547465304
1 parent d70e3de commit 533fbbb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

python/google/protobuf/internal/well_known_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def _SetStructValue(struct_value, value):
446446
elif isinstance(value, (dict, Struct)):
447447
struct_value.struct_value.Clear()
448448
struct_value.struct_value.update(value)
449-
elif isinstance(value, (list, ListValue)):
449+
elif isinstance(value, (list, tuple, ListValue)):
450450
struct_value.list_value.Clear()
451451
struct_value.list_value.extend(value)
452452
else:

python/google/protobuf/internal/well_known_types_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ def testMergeFrom(self):
528528
'key5': [6, 'seven', True, False, None, {'subkey2': 9}],
529529
'key6': [['nested_list', True]],
530530
'empty_struct': {},
531-
'empty_list': []
531+
'empty_list': [],
532+
'tuple': ((3,2), ())
532533
}
533534
struct.update(dictionary)
534535
self.assertEqual(5, struct['key1'])

0 commit comments

Comments
 (0)