File tree Expand file tree Collapse file tree
packages/proto-plus/proto/marshal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919# not be included.
2020
2121from google .protobuf .internal import containers
22- import google .protobuf
23-
24- PROTOBUF_VERSION = google .protobuf .__version__
2522
2623# Import protobuf 4.xx first and fallback to earlier version
2724# if not present.
5148 repeated_composite_types += (_message .RepeatedCompositeContainer ,)
5249 repeated_scalar_types += (_message .RepeatedScalarContainer ,)
5350
54- # In `proto/marshal.py`, for compatibility with protobuf 5.x,
55- # we'll use `map_composite_type_names` to check whether
56- # the name of the class of a protobuf type is
57- # `MessageMapContainer`, and, if `True`, return a MapComposite.
58- # See https://github.com/protocolbuffers/protobuf/issues/16596
59- if PROTOBUF_VERSION [0 :2 ] in ["3." , "4." ]:
51+ try :
6052 map_composite_types += (_message .MessageMapContainer ,)
53+ except AttributeError :
54+ # The `MessageMapContainer` attribute is not available in Protobuf 5.x+
55+ pass
56+
6157
6258__all__ = (
6359 "repeated_composite_types" ,
You can’t perform that action at this time.
0 commit comments