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

New argument create_key in Python #7672

Closed
craynic opened this issue Jul 1, 2020 · 7 comments
Closed

New argument create_key in Python #7672

craynic opened this issue Jul 1, 2020 · 7 comments
Assignees
Labels

Comments

@craynic
Copy link

craynic commented Jul 1, 2020

I noticed that there comes a new argument create_key in class init DescriptorBase. The pb2.py file template also got modified and create_key=_descriptor._internal_create_key added.
It brought me a little trouble because I always use the latest version of protoc to generate Python pb2 files while use them in environments with old protobuf lib installed. After I upgrade protobuf lib, all things get OK.
The errors should look like:

AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'

I see the changes in #7344. But it didn't explain why they are added. Could anyone give a reference about what they are used for?

@jjdressel11
Copy link

This was a breaking change for us. We had to revert to 3.11.4 to generate python files that weren't causing crashes with this error.

@acozzette
Copy link
Member

I'm not familiar with this particular change, but the general rule for Python protobuf is that the protobuf library has to be at least as new as the protoc version used. If you upgrade protoc without upgrading the library, these kind of breakages can occur.

@jjdressel11
Copy link

Having protoc and protobuf at 13.12.4 was causing the following error:

AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'

You should also look into the reason why create_key was added as as an argument to all descriptors without any documentation in #7344

@jjdressel11
Copy link

False alarm on this one. We discovered that Dataflow workers are using the 3.12.2 version of protobuf. Forcing these workers to use version 3.12.4 resolved this issue.

Regardless, there should be documentation for the create_key argument that was added to all descriptors.

@HemantPatil0219
Copy link

I am facing same error i.e AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
i am using protoc version 3.13.0 and protobuf version 3.13.0 both are same still i am facing above error. Help me with this please

@craynic
Copy link
Author

craynic commented Aug 29, 2020

Now I have a new job, so I may not have the need to struggle in gRPC Python any longer, while the doc on why it is added and how it works is still valuable.

And, I don't think submitting a large PR with no comments is a good way to maintain an opensource project. At least, some change-logs could be copied to comment in the PR.

@anandolee
Copy link
Contributor

As acozzette mentioned above "The general rule for Python protobuf is that the protobuf library has to be at least as new as the protoc version used. If you upgrade protoc without upgrading the library, these kind of breakages can occur." This issue is caused because protoc is newer than protobuf runtime. Upgrade the runtime can solve the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants