From 7fd4a15e68f1af91adf4ce6ebd5a40cd57e35661 Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Thu, 18 Jan 2024 14:26:33 +0000 Subject: [PATCH] pb2dict: fix flake8 error This patch fixes the following flake8 error: python3 -m flake8 --config=scripts/flake8.cfg lib/pycriu/images/pb2dict.py lib/pycriu/images/pb2dict.py:361:43: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()` Signed-off-by: Radostin Stoyanov --- lib/pycriu/images/pb2dict.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pycriu/images/pb2dict.py b/lib/pycriu/images/pb2dict.py index 3f5f390e3..d29fdf66c 100644 --- a/lib/pycriu/images/pb2dict.py +++ b/lib/pycriu/images/pb2dict.py @@ -358,7 +358,10 @@ def pb2dict(pb, pretty=False, is_hex=False): else: d_val = _pb2dict_cast(field, value, pretty, is_hex) - d[field.name] = d_val.decode() if type(d_val) == bytes else d_val + try: + d[field.name] = d_val.decode() + except (UnicodeDecodeError, AttributeError): + d[field.name] = d_val return d