Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Import explodes on Python 3.7 #116

Closed

Description

@vmarkovtsev
import bblfsh.github.com.gogo.protobuf.gogoproto.gogo_pb2

fails with

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/bblfsh/github/com/gogo/protobuf/gogoproto/gogo_pb2.py", line 670, in <module>
    google_dot_protobuf_dot_descriptor__pb2.EnumOptions.RegisterExtension(goproto_enum_prefix)
  File "/usr/local/lib/python3.7/site-packages/google/protobuf/internal/python_message.py", line 751, in RegisterExtension
    cls.DESCRIPTOR.file.pool.AddExtensionDescriptor(extension_handle)
  File "/usr/local/lib/python3.7/site-packages/google/protobuf/descriptor_pool.py", line 264, in AddExtensionDescriptor
    extension.containing_type.full_name, extension.number))
AssertionError: Extensions "gogoproto.goproto_enum_prefix" and "gogoproto.goproto_enum_prefix" both try to extend message type "google.protobuf.EnumOptions" with field number 62001.

Reproducible exclusively on Python 3.7.0 final (works fine with beta3). How to reproduce:

docker run -it --rm python:3.7.0-stretch bash
pip3 install bblfsh
python3 -c "import bblfsh.github.com.gogo.protobuf.gogoproto.gogo_pb2"

Related to protocolbuffers/protobuf#2533 but not really.

Looks like the top-level import of bblfsh is not visible to the import system and it imports the module twice. The workaround is to comment out that assertion inside protobuf.

Activity

  1. added 2 commits that reference this issue on Aug 9, 2018
    60b9aff
    926e05c
  2. vmarkovtsev commented on Aug 9, 2018

    @vmarkovtsev
    ContributorAuthor

    Yes, the problem is that import github.com.gogo.protobuf.gogoproto.gogo_pb2 with sweded sys.path and import bblfsh.github.com.gogo.protobuf.gogoproto.gogo_pb2 are different from 3.7's point of view. The solution is to make the internal imports absolute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions