2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

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

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Ruslan Kuprieiev
2015-01-22 18:58:06 +03:00
committed by Pavel Emelyanov
parent b025ef1dbc
commit 0dc9c9837f

View File

@@ -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):
"""