Killian De Smedt committed 41ad16c

Added deserialization to the extended lexer case for native types, fixed issues in this progress

  • Participants
  • Parent commits 8051288

Comments (0)

Files changed (2)

File protobuf/

         value, bytestring = _wiretype_decoder[tag[0] & 0b111](bytestring)
         yield (tag, value)
-_type_decoder = {'fixed32': Struct('<I').unpack,
-                 'sfixed32': Struct('<i').unpack,
-                 'float': Struct('<f').unpack,
+_type_decoder = {'fixed32': lambda x: Struct('<I').unpack(x)[0],
+                 'sfixed32': lambda x: Struct('<i').unpack(x)[0],
+                 'float': lambda x: Struct('<f').unpack(x)[0],
                  'string': lambda raw: raw.decode("UTF-8"),
                  'bytes': lambda raw: raw,
                  'composed': lambda raw: _decode_msg(raw),
                  'repeated': lambda raw: raw,
-                 'fixed64': Struct('<Q').unpack,
-                 'sfixed64': Struct('<q').unpack,
-                 'double': Struct('<d').unpack,
+                 'fixed64': lambda x: Struct('<Q').unpack(x)[0],
+                 'sfixed64': lambda x: Struct('<q').unpack(x)[0],
+                 'double': lambda x: Struct('<d').unpack(x)[0],
                  'int32': lambda n: Struct('i').unpack(Struct('I').pack(n))[0],
                  'int64': lambda n: Struct('q').unpack(Struct('Q').pack(n))[0],
                  'uint32': lambda raw: raw,

File protobuf_test/

         for (varname, val, extra_encoding) in tests:
             kwargs[varname] = val
             expected += extra_encoding
-            self.assertEqual(Test(**kwargs).serialize_to_string(), expected, varname)
+            self.assertEqual(Test(**kwargs).serialize_to_string(), expected, "serialize up to {}".format(varname))
+            self.assertEqual(Test(**kwargs),Test(expected), "deserialize up to {}".format(varname))
 if __name__ == "__main__":
     # import sys;sys.argv = ['', 'Test.testName']