Strange. It looks like there is a bug in the type checker for booleans -- it will accept any integer. However, this doesn't explain the encoding error. Looking at the code, I can't see how this could happen; any non-zero integer value should result in 1 being written to the wire. The problem you describe sounds like an obscure problem that happens in C++, but I can't see why it would happen in Python.
What version of protobufs are you using? On Thu, Dec 23, 2010 at 10:10 PM, BigBaaadBob <[email protected]> wrote: > Turns out it is simple: put a big number into a bool. The encoding > side doesn't complain, but the decoder does. A bug on my part, but > suboptimal behavior for the library. > > On Dec 22, 6:09 pm, Kenton Varda <[email protected]> wrote: > > Can you provide a small, self-contained example program demonstrating > this > > problem? > > > > > > > > > > > > > > > > On Wed, Dec 22, 2010 at 4:52 PM, BigBaaadBob <[email protected]> > wrote: > > > I have Python code doing something like this: > > > > > m.whatever = somevalue; etc..... > > > s = m.SerializeToString() > > > m.Clear() > > > m.ParseFromString(s) > > > > > And the m.ParseFromString throws "google.protobuf.message.DecodeError: > > > Truncated varint." (And this is the only error thrown! If I print m I > > > don't get any errors.) > > > > > It seems like protobuf should be able to read something it > > > successfully creates, no? > > > > > Suggestions? > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Protocol Buffers" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<protobuf%[email protected]> > <protobuf%[email protected] om> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/protobuf?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<protobuf%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
