From 6d27cac6b37ce91c46cb2b6d0a57640926e8bb47 Mon Sep 17 00:00:00 2001 From: mahaloz Date: Wed, 5 Jun 2024 18:32:39 -0700 Subject: [PATCH] Fix a state dumping bug --- libbs/__init__.py | 2 +- libbs/artifacts/artifact.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libbs/__init__.py b/libbs/__init__.py index 4ee64d13..a265e1f2 100644 --- a/libbs/__init__.py +++ b/libbs/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.7.0" +__version__ = "1.7.1" import logging logging.getLogger("libbs").addHandler(logging.NullHandler()) diff --git a/libbs/artifacts/artifact.py b/libbs/artifacts/artifact.py index 05045b9a..2569b1fe 100644 --- a/libbs/artifacts/artifact.py +++ b/libbs/artifacts/artifact.py @@ -125,9 +125,13 @@ def load(cls, fp, fmt=ArtifactFormat.TOML): @classmethod def dumps_many(cls, artifacts: List["Artifact"], key_attr=ADDR_ATTR, fmt=ArtifactFormat.TOML) -> str: - artifacts_dict = { - getattr(art, key_attr): art.__getstate__() for art in artifacts - } + artifacts_dict = {} + for art in artifacts: + k = getattr(art, key_attr) + if isinstance(k, int): + k = hex(k) + + artifacts_dict[k] = art.__getstate__() if fmt == ArtifactFormat.TOML: return toml.dumps(artifacts_dict, encoder=TomlHexEncoder())