Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed the compatibility with conda, protobuf 4 and pyext protobuf #471

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions proto/marshal/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
except ImportError:
_message = None

if not _message:
try:
from google.protobuf.pyext import _message
except ImportError:
_message = None

repeated_composite_types = (containers.RepeatedCompositeFieldContainer,)
repeated_scalar_types = (containers.RepeatedScalarFieldContainer,)
map_composite_types = (containers.MessageMap,)
Expand All @@ -55,6 +49,25 @@
pass



try:
from google.protobuf.pyext import _message as _message_pyext
except ImportError:
_message_pyext = None
Comment on lines +53 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this import statement to the top of the file since we're importing it as _message_pyext


if _message_pyext:
repeated_composite_types += (_message_pyext.RepeatedCompositeContainer,)
repeated_scalar_types += (_message_pyext.RepeatedScalarContainer,)

# In `proto/marshal.py`, for compatibility with protobuf 5.x,
# we'll use `map_composite_type_names` to check whether
# the name of the class of a protobuf type is
# `MessageMapContainer`, and, if `True`, return a MapComposite.
# See https://github.com/protocolbuffers/protobuf/issues/16596
if PROTOBUF_VERSION[0:2] in ["3.", "4."]:
map_composite_types += (_message_pyext.MessageMapContainer,)


__all__ = (
"repeated_composite_types",
"repeated_scalar_types",
Expand Down
Loading