Commit 0dc9c983 authored by Ruslan Kuprieiev's avatar Ruslan Kuprieiev Committed by Pavel Emelyanov

pycriu: images: pb2dict: don't forget to throw an exception, if field has unsupported type

Signed-off-by: 's avatarRuslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b025ef1d
......@@ -93,7 +93,7 @@ def _dict2pb_cast(field, value):
return value.decode('base64')
elif field.type == FD.TYPE_ENUM:
return field.enum_type.values_by_name.get(value, None).number
else:
elif field.type in _basic_cast:
cast = _basic_cast[field.type]
if (cast == int or cast == long) and isinstance(value, unicode):
# Some int or long fields might be stored as hex
......@@ -101,6 +101,8 @@ def _dict2pb_cast(field, value):
return cast(value, 0)
else:
return cast(value)
else:
raise Exception("Field(%s) has unsupported type %d" % (field.name, field.type))
def dict2pb(d, pb):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment