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

Ruslan Kuprieiev kupruser at gmail.com
Wed Jan 21 04:47:20 PST 2015


Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 pycriu/images/pb2dict.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pycriu/images/pb2dict.py b/pycriu/images/pb2dict.py
index d817793..d2c3cc5 100644
--- a/pycriu/images/pb2dict.py
+++ b/pycriu/images/pb2dict.py
@@ -91,7 +91,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
@@ -99,6 +99,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):
 	"""
-- 
2.1.0



More information about the CRIU mailing list