mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-03 07:45:17 +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:
committed by
Pavel Emelyanov
parent
b025ef1dbc
commit
0dc9c9837f
@@ -93,7 +93,7 @@ def _dict2pb_cast(field, value):
|
|||||||
return value.decode('base64')
|
return value.decode('base64')
|
||||||
elif field.type == FD.TYPE_ENUM:
|
elif field.type == FD.TYPE_ENUM:
|
||||||
return field.enum_type.values_by_name.get(value, None).number
|
return field.enum_type.values_by_name.get(value, None).number
|
||||||
else:
|
elif field.type in _basic_cast:
|
||||||
cast = _basic_cast[field.type]
|
cast = _basic_cast[field.type]
|
||||||
if (cast == int or cast == long) and isinstance(value, unicode):
|
if (cast == int or cast == long) and isinstance(value, unicode):
|
||||||
# Some int or long fields might be stored as hex
|
# Some int or long fields might be stored as hex
|
||||||
@@ -101,6 +101,8 @@ def _dict2pb_cast(field, value):
|
|||||||
return cast(value, 0)
|
return cast(value, 0)
|
||||||
else:
|
else:
|
||||||
return cast(value)
|
return cast(value)
|
||||||
|
else:
|
||||||
|
raise Exception("Field(%s) has unsupported type %d" % (field.name, field.type))
|
||||||
|
|
||||||
def dict2pb(d, pb):
|
def dict2pb(d, pb):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user