Skip to content

Conversation

@mfan
Copy link

@mfan mfan commented Apr 21, 2015

Notice that for json2pb.py, using test.proto, the value for '_bin' field is incorrectly serialized into '0a0a0a0a\n' after doing json->pb->json.

As shown in http://bugs.python.org/issue17714, python str.encode() with 'base64' as argument adds a trailing new line character to the returned string. This causes the bug in json2pb.py when handling bytes field.

  • Replaced str.encode('base64') with base64.b64encode(str).
  • Added a unit test for json2pb.py. Test case 'test_bytes_base64' shall fail without the fix.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant