protobuf 6.30.0__cp39-cp39-win_amd64.whl → 6.33.2__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/_upb/_message.cp39-win_amd64.pyd +0 -0
- google/protobuf/__init__.py +1 -1
- google/protobuf/any.py +15 -1
- google/protobuf/any_pb2.py +3 -3
- google/protobuf/api_pb2.py +13 -9
- google/protobuf/compiler/plugin_pb2.py +3 -3
- google/protobuf/descriptor.py +413 -248
- google/protobuf/descriptor_pb2.py +273 -120
- google/protobuf/descriptor_pool.py +27 -12
- google/protobuf/duration_pb2.py +3 -3
- google/protobuf/empty_pb2.py +3 -3
- google/protobuf/field_mask_pb2.py +3 -3
- google/protobuf/internal/api_implementation.py +0 -6
- google/protobuf/internal/decoder.py +106 -23
- google/protobuf/internal/extension_dict.py +3 -3
- google/protobuf/internal/field_mask.py +6 -4
- google/protobuf/internal/python_edition_defaults.py +1 -1
- google/protobuf/internal/python_message.py +71 -52
- google/protobuf/internal/testing_refleaks.py +8 -2
- google/protobuf/internal/type_checkers.py +47 -5
- google/protobuf/internal/well_known_types.py +60 -43
- google/protobuf/json_format.py +88 -62
- google/protobuf/message_factory.py +16 -0
- google/protobuf/runtime_version.py +7 -27
- google/protobuf/source_context_pb2.py +3 -3
- google/protobuf/struct_pb2.py +3 -3
- google/protobuf/text_format.py +41 -26
- google/protobuf/timestamp_pb2.py +3 -3
- google/protobuf/type_pb2.py +3 -3
- google/protobuf/wrappers_pb2.py +3 -3
- {protobuf-6.30.0.dist-info → protobuf-6.33.2.dist-info}/METADATA +1 -1
- protobuf-6.33.2.dist-info/RECORD +59 -0
- protobuf-6.30.0.dist-info/RECORD +0 -59
- {protobuf-6.30.0.dist-info → protobuf-6.33.2.dist-info}/LICENSE +0 -0
- {protobuf-6.30.0.dist-info → protobuf-6.33.2.dist-info}/WHEEL +0 -0
|
@@ -75,7 +75,8 @@ def _IsMessageSetExtension(field):
|
|
|
75
75
|
field.containing_type.has_options and
|
|
76
76
|
field.containing_type.GetOptions().message_set_wire_format and
|
|
77
77
|
field.type == descriptor.FieldDescriptor.TYPE_MESSAGE and
|
|
78
|
-
field.
|
|
78
|
+
not field.is_required and
|
|
79
|
+
not field.is_repeated)
|
|
79
80
|
|
|
80
81
|
_edition_defaults_lock = threading.Lock()
|
|
81
82
|
|
|
@@ -85,9 +86,9 @@ class DescriptorPool(object):
|
|
|
85
86
|
|
|
86
87
|
if _USE_C_DESCRIPTORS:
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
def __new__(cls, descriptor_db=None):
|
|
90
|
+
# pylint: disable=protected-access
|
|
91
|
+
return descriptor._message.DescriptorPool(descriptor_db)
|
|
91
92
|
|
|
92
93
|
def __init__(
|
|
93
94
|
self, descriptor_db=None, use_deprecated_legacy_json_field_conflicts=False
|
|
@@ -580,11 +581,21 @@ class DescriptorPool(object):
|
|
|
580
581
|
if self._descriptor_db and hasattr(
|
|
581
582
|
self._descriptor_db, 'FindAllExtensionNumbers'):
|
|
582
583
|
full_name = message_descriptor.full_name
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
584
|
+
try:
|
|
585
|
+
all_numbers = self._descriptor_db.FindAllExtensionNumbers(full_name)
|
|
586
|
+
except:
|
|
587
|
+
pass
|
|
588
|
+
else:
|
|
589
|
+
if isinstance(all_numbers, list):
|
|
590
|
+
for number in all_numbers:
|
|
591
|
+
if number in self._extensions_by_number[message_descriptor]:
|
|
592
|
+
continue
|
|
593
|
+
self._TryLoadExtensionFromDB(message_descriptor, number)
|
|
594
|
+
else:
|
|
595
|
+
warnings.warn(
|
|
596
|
+
'FindAllExtensionNumbers() on fall back DB must return a list,'
|
|
597
|
+
' not {0}'.format(type(all_numbers))
|
|
598
|
+
)
|
|
588
599
|
|
|
589
600
|
return list(self._extensions_by_number[message_descriptor].values())
|
|
590
601
|
|
|
@@ -603,8 +614,13 @@ class DescriptorPool(object):
|
|
|
603
614
|
return
|
|
604
615
|
|
|
605
616
|
full_name = message_descriptor.full_name
|
|
606
|
-
file_proto =
|
|
607
|
-
|
|
617
|
+
file_proto = None
|
|
618
|
+
try:
|
|
619
|
+
file_proto = self._descriptor_db.FindFileContainingExtension(
|
|
620
|
+
full_name, number
|
|
621
|
+
)
|
|
622
|
+
except:
|
|
623
|
+
return
|
|
608
624
|
|
|
609
625
|
if file_proto is None:
|
|
610
626
|
return
|
|
@@ -668,7 +684,6 @@ class DescriptorPool(object):
|
|
|
668
684
|
if not isinstance(defaults, descriptor_pb2.FeatureSetDefaults):
|
|
669
685
|
raise TypeError('SetFeatureSetDefaults called with invalid type')
|
|
670
686
|
|
|
671
|
-
|
|
672
687
|
if defaults.minimum_edition > defaults.maximum_edition:
|
|
673
688
|
raise ValueError(
|
|
674
689
|
'Invalid edition range %s to %s'
|
google/protobuf/duration_pb2.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/duration.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.33.2
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,8 +12,8 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
33,
|
|
16
|
+
2,
|
|
17
17
|
'',
|
|
18
18
|
'google/protobuf/duration.proto'
|
|
19
19
|
)
|
google/protobuf/empty_pb2.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/empty.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.33.2
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,8 +12,8 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
33,
|
|
16
|
+
2,
|
|
17
17
|
'',
|
|
18
18
|
'google/protobuf/empty.proto'
|
|
19
19
|
)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/field_mask.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.33.2
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,8 +12,8 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
33,
|
|
16
|
+
2,
|
|
17
17
|
'',
|
|
18
18
|
'google/protobuf/field_mask.proto'
|
|
19
19
|
)
|
|
@@ -131,12 +131,6 @@ def Type():
|
|
|
131
131
|
return _implementation_type
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
# See comment on 'Type' above.
|
|
135
|
-
# TODO: Remove the API, it returns a constant. b/228102101
|
|
136
|
-
def Version():
|
|
137
|
-
return 2
|
|
138
|
-
|
|
139
|
-
|
|
140
134
|
# For internal use only
|
|
141
135
|
def IsPythonDefaultSerializationDeterministic():
|
|
142
136
|
return _python_deterministic_proto_serialization
|
|
@@ -219,7 +219,10 @@ def _SimpleDecoder(wire_type, decode_value):
|
|
|
219
219
|
clear_if_default=False):
|
|
220
220
|
if is_packed:
|
|
221
221
|
local_DecodeVarint = _DecodeVarint
|
|
222
|
-
def DecodePackedField(
|
|
222
|
+
def DecodePackedField(
|
|
223
|
+
buffer, pos, end, message, field_dict, current_depth=0
|
|
224
|
+
):
|
|
225
|
+
del current_depth # unused
|
|
223
226
|
value = field_dict.get(key)
|
|
224
227
|
if value is None:
|
|
225
228
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -234,11 +237,15 @@ def _SimpleDecoder(wire_type, decode_value):
|
|
|
234
237
|
del value[-1] # Discard corrupt value.
|
|
235
238
|
raise _DecodeError('Packed element was truncated.')
|
|
236
239
|
return pos
|
|
240
|
+
|
|
237
241
|
return DecodePackedField
|
|
238
242
|
elif is_repeated:
|
|
239
243
|
tag_bytes = encoder.TagBytes(field_number, wire_type)
|
|
240
244
|
tag_len = len(tag_bytes)
|
|
241
|
-
def DecodeRepeatedField(
|
|
245
|
+
def DecodeRepeatedField(
|
|
246
|
+
buffer, pos, end, message, field_dict, current_depth=0
|
|
247
|
+
):
|
|
248
|
+
del current_depth # unused
|
|
242
249
|
value = field_dict.get(key)
|
|
243
250
|
if value is None:
|
|
244
251
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -253,9 +260,12 @@ def _SimpleDecoder(wire_type, decode_value):
|
|
|
253
260
|
if new_pos > end:
|
|
254
261
|
raise _DecodeError('Truncated message.')
|
|
255
262
|
return new_pos
|
|
263
|
+
|
|
256
264
|
return DecodeRepeatedField
|
|
257
265
|
else:
|
|
258
|
-
|
|
266
|
+
|
|
267
|
+
def DecodeField(buffer, pos, end, message, field_dict, current_depth=0):
|
|
268
|
+
del current_depth # unused
|
|
259
269
|
(new_value, pos) = decode_value(buffer, pos)
|
|
260
270
|
if pos > end:
|
|
261
271
|
raise _DecodeError('Truncated message.')
|
|
@@ -264,6 +274,7 @@ def _SimpleDecoder(wire_type, decode_value):
|
|
|
264
274
|
else:
|
|
265
275
|
field_dict[key] = new_value
|
|
266
276
|
return pos
|
|
277
|
+
|
|
267
278
|
return DecodeField
|
|
268
279
|
|
|
269
280
|
return SpecificDecoder
|
|
@@ -399,7 +410,9 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
399
410
|
enum_type = key.enum_type
|
|
400
411
|
if is_packed:
|
|
401
412
|
local_DecodeVarint = _DecodeVarint
|
|
402
|
-
def DecodePackedField(
|
|
413
|
+
def DecodePackedField(
|
|
414
|
+
buffer, pos, end, message, field_dict, current_depth=0
|
|
415
|
+
):
|
|
403
416
|
"""Decode serialized packed enum to its value and a new position.
|
|
404
417
|
|
|
405
418
|
Args:
|
|
@@ -412,6 +425,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
412
425
|
Returns:
|
|
413
426
|
int, new position in serialized data.
|
|
414
427
|
"""
|
|
428
|
+
del current_depth # unused
|
|
415
429
|
value = field_dict.get(key)
|
|
416
430
|
if value is None:
|
|
417
431
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -442,11 +456,14 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
442
456
|
# pylint: enable=protected-access
|
|
443
457
|
raise _DecodeError('Packed element was truncated.')
|
|
444
458
|
return pos
|
|
459
|
+
|
|
445
460
|
return DecodePackedField
|
|
446
461
|
elif is_repeated:
|
|
447
462
|
tag_bytes = encoder.TagBytes(field_number, wire_format.WIRETYPE_VARINT)
|
|
448
463
|
tag_len = len(tag_bytes)
|
|
449
|
-
def DecodeRepeatedField(
|
|
464
|
+
def DecodeRepeatedField(
|
|
465
|
+
buffer, pos, end, message, field_dict, current_depth=0
|
|
466
|
+
):
|
|
450
467
|
"""Decode serialized repeated enum to its value and a new position.
|
|
451
468
|
|
|
452
469
|
Args:
|
|
@@ -459,6 +476,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
459
476
|
Returns:
|
|
460
477
|
int, new position in serialized data.
|
|
461
478
|
"""
|
|
479
|
+
del current_depth # unused
|
|
462
480
|
value = field_dict.get(key)
|
|
463
481
|
if value is None:
|
|
464
482
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -481,9 +499,11 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
481
499
|
if new_pos > end:
|
|
482
500
|
raise _DecodeError('Truncated message.')
|
|
483
501
|
return new_pos
|
|
502
|
+
|
|
484
503
|
return DecodeRepeatedField
|
|
485
504
|
else:
|
|
486
|
-
|
|
505
|
+
|
|
506
|
+
def DecodeField(buffer, pos, end, message, field_dict, current_depth=0):
|
|
487
507
|
"""Decode serialized repeated enum to its value and a new position.
|
|
488
508
|
|
|
489
509
|
Args:
|
|
@@ -496,6 +516,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
496
516
|
Returns:
|
|
497
517
|
int, new position in serialized data.
|
|
498
518
|
"""
|
|
519
|
+
del current_depth # unused
|
|
499
520
|
value_start_pos = pos
|
|
500
521
|
(enum_value, pos) = _DecodeSignedVarint32(buffer, pos)
|
|
501
522
|
if pos > end:
|
|
@@ -515,6 +536,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
515
536
|
(tag_bytes, buffer[value_start_pos:pos].tobytes()))
|
|
516
537
|
# pylint: enable=protected-access
|
|
517
538
|
return pos
|
|
539
|
+
|
|
518
540
|
return DecodeField
|
|
519
541
|
|
|
520
542
|
|
|
@@ -573,7 +595,10 @@ def StringDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
573
595
|
tag_bytes = encoder.TagBytes(field_number,
|
|
574
596
|
wire_format.WIRETYPE_LENGTH_DELIMITED)
|
|
575
597
|
tag_len = len(tag_bytes)
|
|
576
|
-
def DecodeRepeatedField(
|
|
598
|
+
def DecodeRepeatedField(
|
|
599
|
+
buffer, pos, end, message, field_dict, current_depth=0
|
|
600
|
+
):
|
|
601
|
+
del current_depth # unused
|
|
577
602
|
value = field_dict.get(key)
|
|
578
603
|
if value is None:
|
|
579
604
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -588,9 +613,12 @@ def StringDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
588
613
|
if buffer[new_pos:pos] != tag_bytes or new_pos == end:
|
|
589
614
|
# Prediction failed. Return.
|
|
590
615
|
return new_pos
|
|
616
|
+
|
|
591
617
|
return DecodeRepeatedField
|
|
592
618
|
else:
|
|
593
|
-
|
|
619
|
+
|
|
620
|
+
def DecodeField(buffer, pos, end, message, field_dict, current_depth=0):
|
|
621
|
+
del current_depth # unused
|
|
594
622
|
(size, pos) = local_DecodeVarint(buffer, pos)
|
|
595
623
|
new_pos = pos + size
|
|
596
624
|
if new_pos > end:
|
|
@@ -600,6 +628,7 @@ def StringDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
600
628
|
else:
|
|
601
629
|
field_dict[key] = _ConvertToUnicode(buffer[pos:new_pos])
|
|
602
630
|
return new_pos
|
|
631
|
+
|
|
603
632
|
return DecodeField
|
|
604
633
|
|
|
605
634
|
|
|
@@ -614,7 +643,10 @@ def BytesDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
614
643
|
tag_bytes = encoder.TagBytes(field_number,
|
|
615
644
|
wire_format.WIRETYPE_LENGTH_DELIMITED)
|
|
616
645
|
tag_len = len(tag_bytes)
|
|
617
|
-
def DecodeRepeatedField(
|
|
646
|
+
def DecodeRepeatedField(
|
|
647
|
+
buffer, pos, end, message, field_dict, current_depth=0
|
|
648
|
+
):
|
|
649
|
+
del current_depth # unused
|
|
618
650
|
value = field_dict.get(key)
|
|
619
651
|
if value is None:
|
|
620
652
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -629,9 +661,12 @@ def BytesDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
629
661
|
if buffer[new_pos:pos] != tag_bytes or new_pos == end:
|
|
630
662
|
# Prediction failed. Return.
|
|
631
663
|
return new_pos
|
|
664
|
+
|
|
632
665
|
return DecodeRepeatedField
|
|
633
666
|
else:
|
|
634
|
-
|
|
667
|
+
|
|
668
|
+
def DecodeField(buffer, pos, end, message, field_dict, current_depth=0):
|
|
669
|
+
del current_depth # unused
|
|
635
670
|
(size, pos) = local_DecodeVarint(buffer, pos)
|
|
636
671
|
new_pos = pos + size
|
|
637
672
|
if new_pos > end:
|
|
@@ -641,6 +676,7 @@ def BytesDecoder(field_number, is_repeated, is_packed, key, new_default,
|
|
|
641
676
|
else:
|
|
642
677
|
field_dict[key] = buffer[pos:new_pos].tobytes()
|
|
643
678
|
return new_pos
|
|
679
|
+
|
|
644
680
|
return DecodeField
|
|
645
681
|
|
|
646
682
|
|
|
@@ -656,7 +692,9 @@ def GroupDecoder(field_number, is_repeated, is_packed, key, new_default):
|
|
|
656
692
|
tag_bytes = encoder.TagBytes(field_number,
|
|
657
693
|
wire_format.WIRETYPE_START_GROUP)
|
|
658
694
|
tag_len = len(tag_bytes)
|
|
659
|
-
def DecodeRepeatedField(
|
|
695
|
+
def DecodeRepeatedField(
|
|
696
|
+
buffer, pos, end, message, field_dict, current_depth=0
|
|
697
|
+
):
|
|
660
698
|
value = field_dict.get(key)
|
|
661
699
|
if value is None:
|
|
662
700
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -665,7 +703,13 @@ def GroupDecoder(field_number, is_repeated, is_packed, key, new_default):
|
|
|
665
703
|
if value is None:
|
|
666
704
|
value = field_dict.setdefault(key, new_default(message))
|
|
667
705
|
# Read sub-message.
|
|
668
|
-
|
|
706
|
+
current_depth += 1
|
|
707
|
+
if current_depth > _recursion_limit:
|
|
708
|
+
raise _DecodeError(
|
|
709
|
+
'Error parsing message: too many levels of nesting.'
|
|
710
|
+
)
|
|
711
|
+
pos = value.add()._InternalParse(buffer, pos, end, current_depth)
|
|
712
|
+
current_depth -= 1
|
|
669
713
|
# Read end tag.
|
|
670
714
|
new_pos = pos+end_tag_len
|
|
671
715
|
if buffer[pos:new_pos] != end_tag_bytes or new_pos > end:
|
|
@@ -675,19 +719,26 @@ def GroupDecoder(field_number, is_repeated, is_packed, key, new_default):
|
|
|
675
719
|
if buffer[new_pos:pos] != tag_bytes or new_pos == end:
|
|
676
720
|
# Prediction failed. Return.
|
|
677
721
|
return new_pos
|
|
722
|
+
|
|
678
723
|
return DecodeRepeatedField
|
|
679
724
|
else:
|
|
680
|
-
|
|
725
|
+
|
|
726
|
+
def DecodeField(buffer, pos, end, message, field_dict, current_depth=0):
|
|
681
727
|
value = field_dict.get(key)
|
|
682
728
|
if value is None:
|
|
683
729
|
value = field_dict.setdefault(key, new_default(message))
|
|
684
730
|
# Read sub-message.
|
|
685
|
-
|
|
731
|
+
current_depth += 1
|
|
732
|
+
if current_depth > _recursion_limit:
|
|
733
|
+
raise _DecodeError('Error parsing message: too many levels of nesting.')
|
|
734
|
+
pos = value._InternalParse(buffer, pos, end, current_depth)
|
|
735
|
+
current_depth -= 1
|
|
686
736
|
# Read end tag.
|
|
687
737
|
new_pos = pos+end_tag_len
|
|
688
738
|
if buffer[pos:new_pos] != end_tag_bytes or new_pos > end:
|
|
689
739
|
raise _DecodeError('Missing group end tag.')
|
|
690
740
|
return new_pos
|
|
741
|
+
|
|
691
742
|
return DecodeField
|
|
692
743
|
|
|
693
744
|
|
|
@@ -701,7 +752,9 @@ def MessageDecoder(field_number, is_repeated, is_packed, key, new_default):
|
|
|
701
752
|
tag_bytes = encoder.TagBytes(field_number,
|
|
702
753
|
wire_format.WIRETYPE_LENGTH_DELIMITED)
|
|
703
754
|
tag_len = len(tag_bytes)
|
|
704
|
-
def DecodeRepeatedField(
|
|
755
|
+
def DecodeRepeatedField(
|
|
756
|
+
buffer, pos, end, message, field_dict, current_depth=0
|
|
757
|
+
):
|
|
705
758
|
value = field_dict.get(key)
|
|
706
759
|
if value is None:
|
|
707
760
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -712,18 +765,29 @@ def MessageDecoder(field_number, is_repeated, is_packed, key, new_default):
|
|
|
712
765
|
if new_pos > end:
|
|
713
766
|
raise _DecodeError('Truncated message.')
|
|
714
767
|
# Read sub-message.
|
|
715
|
-
|
|
768
|
+
current_depth += 1
|
|
769
|
+
if current_depth > _recursion_limit:
|
|
770
|
+
raise _DecodeError(
|
|
771
|
+
'Error parsing message: too many levels of nesting.'
|
|
772
|
+
)
|
|
773
|
+
if (
|
|
774
|
+
value.add()._InternalParse(buffer, pos, new_pos, current_depth)
|
|
775
|
+
!= new_pos
|
|
776
|
+
):
|
|
716
777
|
# The only reason _InternalParse would return early is if it
|
|
717
778
|
# encountered an end-group tag.
|
|
718
779
|
raise _DecodeError('Unexpected end-group tag.')
|
|
780
|
+
current_depth -= 1
|
|
719
781
|
# Predict that the next tag is another copy of the same repeated field.
|
|
720
782
|
pos = new_pos + tag_len
|
|
721
783
|
if buffer[new_pos:pos] != tag_bytes or new_pos == end:
|
|
722
784
|
# Prediction failed. Return.
|
|
723
785
|
return new_pos
|
|
786
|
+
|
|
724
787
|
return DecodeRepeatedField
|
|
725
788
|
else:
|
|
726
|
-
|
|
789
|
+
|
|
790
|
+
def DecodeField(buffer, pos, end, message, field_dict, current_depth=0):
|
|
727
791
|
value = field_dict.get(key)
|
|
728
792
|
if value is None:
|
|
729
793
|
value = field_dict.setdefault(key, new_default(message))
|
|
@@ -733,11 +797,16 @@ def MessageDecoder(field_number, is_repeated, is_packed, key, new_default):
|
|
|
733
797
|
if new_pos > end:
|
|
734
798
|
raise _DecodeError('Truncated message.')
|
|
735
799
|
# Read sub-message.
|
|
736
|
-
|
|
800
|
+
current_depth += 1
|
|
801
|
+
if current_depth > _recursion_limit:
|
|
802
|
+
raise _DecodeError('Error parsing message: too many levels of nesting.')
|
|
803
|
+
if value._InternalParse(buffer, pos, new_pos, current_depth) != new_pos:
|
|
737
804
|
# The only reason _InternalParse would return early is if it encountered
|
|
738
805
|
# an end-group tag.
|
|
739
806
|
raise _DecodeError('Unexpected end-group tag.')
|
|
807
|
+
current_depth -= 1
|
|
740
808
|
return new_pos
|
|
809
|
+
|
|
741
810
|
return DecodeField
|
|
742
811
|
|
|
743
812
|
|
|
@@ -887,7 +956,8 @@ def MapDecoder(field_descriptor, new_default, is_message_map):
|
|
|
887
956
|
# Can't read _concrete_class yet; might not be initialized.
|
|
888
957
|
message_type = field_descriptor.message_type
|
|
889
958
|
|
|
890
|
-
def DecodeMap(buffer, pos, end, message, field_dict):
|
|
959
|
+
def DecodeMap(buffer, pos, end, message, field_dict, current_depth=0):
|
|
960
|
+
del current_depth # Unused.
|
|
891
961
|
submsg = message_type._concrete_class()
|
|
892
962
|
value = field_dict.get(key)
|
|
893
963
|
if value is None:
|
|
@@ -930,9 +1000,16 @@ def _DecodeFixed32(buffer, pos):
|
|
|
930
1000
|
|
|
931
1001
|
new_pos = pos + 4
|
|
932
1002
|
return (struct.unpack('<I', buffer[pos:new_pos])[0], new_pos)
|
|
1003
|
+
DEFAULT_RECURSION_LIMIT = 100
|
|
1004
|
+
_recursion_limit = DEFAULT_RECURSION_LIMIT
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
def SetRecursionLimit(new_limit):
|
|
1008
|
+
global _recursion_limit
|
|
1009
|
+
_recursion_limit = new_limit
|
|
933
1010
|
|
|
934
1011
|
|
|
935
|
-
def _DecodeUnknownFieldSet(buffer, pos, end_pos=None):
|
|
1012
|
+
def _DecodeUnknownFieldSet(buffer, pos, end_pos=None, current_depth=0):
|
|
936
1013
|
"""Decode UnknownFieldSet. Returns the UnknownFieldSet and new position."""
|
|
937
1014
|
|
|
938
1015
|
unknown_field_set = containers.UnknownFieldSet()
|
|
@@ -943,7 +1020,7 @@ def _DecodeUnknownFieldSet(buffer, pos, end_pos=None):
|
|
|
943
1020
|
if wire_type == wire_format.WIRETYPE_END_GROUP:
|
|
944
1021
|
break
|
|
945
1022
|
(data, pos) = _DecodeUnknownField(
|
|
946
|
-
buffer, pos, end_pos, field_number, wire_type
|
|
1023
|
+
buffer, pos, end_pos, field_number, wire_type, current_depth
|
|
947
1024
|
)
|
|
948
1025
|
# pylint: disable=protected-access
|
|
949
1026
|
unknown_field_set._add(field_number, wire_type, data)
|
|
@@ -951,7 +1028,9 @@ def _DecodeUnknownFieldSet(buffer, pos, end_pos=None):
|
|
|
951
1028
|
return (unknown_field_set, pos)
|
|
952
1029
|
|
|
953
1030
|
|
|
954
|
-
def _DecodeUnknownField(
|
|
1031
|
+
def _DecodeUnknownField(
|
|
1032
|
+
buffer, pos, end_pos, field_number, wire_type, current_depth=0
|
|
1033
|
+
):
|
|
955
1034
|
"""Decode a unknown field. Returns the UnknownField and new position."""
|
|
956
1035
|
|
|
957
1036
|
if wire_type == wire_format.WIRETYPE_VARINT:
|
|
@@ -968,7 +1047,11 @@ def _DecodeUnknownField(buffer, pos, end_pos, field_number, wire_type):
|
|
|
968
1047
|
end_tag_bytes = encoder.TagBytes(
|
|
969
1048
|
field_number, wire_format.WIRETYPE_END_GROUP
|
|
970
1049
|
)
|
|
971
|
-
|
|
1050
|
+
current_depth += 1
|
|
1051
|
+
if current_depth >= _recursion_limit:
|
|
1052
|
+
raise _DecodeError('Error parsing message: too many levels of nesting.')
|
|
1053
|
+
data, pos = _DecodeUnknownFieldSet(buffer, pos, end_pos, current_depth)
|
|
1054
|
+
current_depth -= 1
|
|
972
1055
|
# Check end tag.
|
|
973
1056
|
if buffer[pos - len(end_tag_bytes) : pos] != end_tag_bytes:
|
|
974
1057
|
raise _DecodeError('Missing group end tag.')
|
|
@@ -61,7 +61,7 @@ class _ExtensionDict(object):
|
|
|
61
61
|
if result is not None:
|
|
62
62
|
return result
|
|
63
63
|
|
|
64
|
-
if extension_handle.
|
|
64
|
+
if extension_handle.is_repeated:
|
|
65
65
|
result = extension_handle._default_constructor(self._extended_message)
|
|
66
66
|
elif extension_handle.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE:
|
|
67
67
|
message_type = extension_handle.message_type
|
|
@@ -129,7 +129,7 @@ class _ExtensionDict(object):
|
|
|
129
129
|
|
|
130
130
|
_VerifyExtensionHandle(self._extended_message, extension_handle)
|
|
131
131
|
|
|
132
|
-
if (extension_handle.
|
|
132
|
+
if (extension_handle.is_repeated or
|
|
133
133
|
extension_handle.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE):
|
|
134
134
|
raise TypeError(
|
|
135
135
|
'Cannot assign to extension "%s" because it is a repeated or '
|
|
@@ -183,7 +183,7 @@ class _ExtensionDict(object):
|
|
|
183
183
|
if extension_handle not in self._extended_message._fields:
|
|
184
184
|
return False
|
|
185
185
|
|
|
186
|
-
if extension_handle.
|
|
186
|
+
if extension_handle.is_repeated:
|
|
187
187
|
return bool(self._extended_message._fields.get(extension_handle))
|
|
188
188
|
|
|
189
189
|
if extension_handle.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE:
|
|
@@ -100,7 +100,7 @@ def _IsValidPath(message_descriptor, path):
|
|
|
100
100
|
for name in parts:
|
|
101
101
|
field = message_descriptor.fields_by_name.get(name)
|
|
102
102
|
if (field is None or
|
|
103
|
-
field.
|
|
103
|
+
field.is_repeated or
|
|
104
104
|
field.type != FieldDescriptor.TYPE_MESSAGE):
|
|
105
105
|
return False
|
|
106
106
|
message_descriptor = field.message_type
|
|
@@ -271,7 +271,7 @@ def _MergeMessage(
|
|
|
271
271
|
name, source_descriptor.full_name))
|
|
272
272
|
if child:
|
|
273
273
|
# Sub-paths are only allowed for singular message fields.
|
|
274
|
-
if (field.
|
|
274
|
+
if (field.is_repeated or
|
|
275
275
|
field.cpp_type != FieldDescriptor.CPPTYPE_MESSAGE):
|
|
276
276
|
raise ValueError('Error: Field {0} in message {1} is not a singular '
|
|
277
277
|
'message field and cannot have sub-fields.'.format(
|
|
@@ -281,7 +281,7 @@ def _MergeMessage(
|
|
|
281
281
|
child, getattr(source, name), getattr(destination, name),
|
|
282
282
|
replace_message, replace_repeated)
|
|
283
283
|
continue
|
|
284
|
-
if field.
|
|
284
|
+
if field.is_repeated:
|
|
285
285
|
if replace_repeated:
|
|
286
286
|
destination.ClearField(_StrConvert(name))
|
|
287
287
|
repeated_source = getattr(source, name)
|
|
@@ -293,8 +293,10 @@ def _MergeMessage(
|
|
|
293
293
|
destination.ClearField(_StrConvert(name))
|
|
294
294
|
if source.HasField(name):
|
|
295
295
|
getattr(destination, name).MergeFrom(getattr(source, name))
|
|
296
|
-
|
|
296
|
+
elif not field.has_presence or source.HasField(name):
|
|
297
297
|
setattr(destination, name, getattr(source, name))
|
|
298
|
+
else:
|
|
299
|
+
destination.ClearField(_StrConvert(name))
|
|
298
300
|
|
|
299
301
|
|
|
300
302
|
def _AddFieldPaths(node, prefix, field_mask):
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
This file contains the serialized FeatureSetDefaults object corresponding to
|
|
3
3
|
the Pure Python runtime. This is used for feature resolution under Editions.
|
|
4
4
|
"""
|
|
5
|
-
_PROTOBUF_INTERNAL_PYTHON_EDITION_DEFAULTS = b"\n\
|
|
5
|
+
_PROTOBUF_INTERNAL_PYTHON_EDITION_DEFAULTS = b"\n\027\030\204\007\"\000*\020\010\001\020\002\030\002 \003(\0010\0028\002@\001\n\027\030\347\007\"\000*\020\010\002\020\001\030\001 \002(\0010\0018\002@\001\n\027\030\350\007\"\014\010\001\020\001\030\001 \002(\0010\001*\0048\002@\001\n\027\030\351\007\"\020\010\001\020\001\030\001 \002(\0010\0018\001@\002*\000 \346\007(\351\007"
|