Closed chicagoben closed 11 years ago
Another way is just to reorder the conditional:
if field.type == FieldDescriptor.TYPE_MESSAGE:
type_callable = lambda pb: protobuf_to_dict(pb,
type_callable_map=type_callable_map,
use_enum_labels=use_enum_labels)
elif field.type in type_callable_map: type_callable = type_callable_map[field.type] else: raise TypeError("Field %s.%s has unrecognised type id %d" % (pb.class.name, field.name, field.type))
Doh! That's a dumb bug. Thanks for letting me know. I’ll patch it ASAP :)
Cheers. Thanks for creating this!
If I had nested messages it wouldn't work as is. I had to change the fourth line to be:
if field.type not in type_callable_map and field.type != FieldDescriptor.TYPE_MESSAGE:
I added: "and field.type != FieldDescriptor.TYPE_MESSAGE"
Cheers, Ben