diff --git a/src/coredumpy/py_object_proxy.py b/src/coredumpy/py_object_proxy.py index bc0d360..439c28d 100644 --- a/src/coredumpy/py_object_proxy.py +++ b/src/coredumpy/py_object_proxy.py @@ -64,6 +64,8 @@ def dump_object(cls, obj): return {"type": "None"} elif isinstance(obj, (int, float, str, bool)): return {"type": type(obj).__name__, "value": obj} + elif isinstance(obj, bytes): + return {"type": type(obj).__name__, "value": obj.hex()} elif isinstance(obj, (list, tuple, set)): for item in obj: cls._add_object(item) @@ -87,6 +89,8 @@ def load_object(cls, id, data=None): proxy = None elif data["type"] in ("int", "float", "str", "bool"): proxy = data["value"] + elif data["type"] == "bytes": + proxy = bytes.fromhex(data["value"]) elif data["type"] == "list": proxy = [cls.load_object(item_id, cls._objects.get(item_id)) for item_id in data["value"]] elif data["type"] == "tuple": diff --git a/tests/test_py_object_proxy.py b/tests/test_py_object_proxy.py index bee3573..58409b6 100644 --- a/tests/test_py_object_proxy.py +++ b/tests/test_py_object_proxy.py @@ -46,6 +46,11 @@ def test_bool(self): proxy = self.convert_object(obj) self.assertEqual(proxy, True) + def test_bytes(self): + obj = b"hello" + proxy = self.convert_object(obj) + self.assertEqual(proxy, b"hello") + def test_builtins(self): obj = object() proxy = self.convert_object(obj)