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

Membership test of a key in Map have different behavior in Python & CPP API #4029

Closed
cyyber opened this issue Dec 12, 2017 · 2 comments
Closed
Assignees
Labels

Comments

@cyyber
Copy link
Contributor

cyyber commented Dec 12, 2017

Recently, I have faced an issue using protobuf in Python3, where CPP environ works fine, but python environ fails to find the key. This behavior has recently caused disruption to the distribution of our software using protobuf.

Lets assume the following protoformat

message myData {
map<string, uint64> data = 1;
}

Now lets assume I set the cpp environment I do the following after generating stub.

os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp'
myData.data['hello'] = 10
print(b'hello' in myData.data)

The above would print True, in cpp api of protobuf.
Now lets do the same with python

os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
myData.data['hello'] = 10
print(b'hello' in myData.data)

The above would print False as python api doesn't convert bytes into string.

Due to this, our software, using protobuf, when deployed into different nodes of our users, had mixed result. Users with cpp api of protobuf, in their nodes, our software worked fine, without any problem. But users with the python api of protobuf, had faced a lot of bug just because of this.

@cyyber
Copy link
Contributor Author

cyyber commented Dec 16, 2017

PR #4030 has been updated, still waiting for it to merge to fix this issue.

@acozzette
Copy link
Member

Let me close this issue now that the pull request has been merged. Thanks for the fix!

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

4 participants