0
votes

I'm trying to read a protocol buffer file in Python that was written with Java and I am having issues as i get this error when calling ParseFromString().

  File "build/bdist.linux-x86_64/egg/google/protobuf/message.py", line 182, in ParseFromString
  File "build/bdist.linux-x86_64/egg/google/protobuf/internal/python_message.py", line 795, in MergeFromString
  File "build/bdist.linux-x86_64/egg/google/protobuf/internal/python_message.py", line 819, in InternalParse
  File "build/bdist.linux-x86_64/egg/google/protobuf/internal/decoder.py", line 716, in SkipField
  File "build/bdist.linux-x86_64/egg/google/protobuf/internal/decoder.py", line 685, in _RaiseInvalidWireType
google.protobuf.message.DecodeError: Tag had invalid wire type.

I tried to google and saw this link: http://comments.gmane.org/gmane.comp.lib.protocol-buffers.general/11996

I tried writing a simple protobuf schema and writing it out in Python and I am also able to read it in Python. It's only when the file was created with Java (I haven't tried C++) that I can't read it in Python.

I was wondering if this was in fact true? Mahalo all!

1
Post the code used for message serialization. - engineerC
that's the problem... i don't have the serialization code as another team did it using java. however, i have the .proto files so i used protoc to generate the python classes and tried to parse the binary files with my python scripts when i ran into this issue. i verified i am using the same version of protocol buffers as them (v2.5.0) - mike

1 Answers

0
votes

What is written in the link you post is true, you have to make some sort of delimiter to know where messages start and end. It is also up to you to handle this before pushing the data to the decoder.