From baa58ff831b212874ba4961238acf74036c201c4 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Sun, 22 Feb 2026 21:49:14 +0100 Subject: [PATCH] Fixed a bug --- README.md | 3 +++ pyproject.toml | 2 +- src/jeb_utils/jebp_utils.py | 12 ++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ca57f29..45de270 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,9 @@ pip install jeb-utils --index-url https://jcloud-services.ddns.net/simple/ --ext - `create_file_if_not_exists`: Creates a file if it does not exist. ## Changelog +### Version 0.1.4 +- Bug fix: Due to a refactoring, `jeb_utils.jebp_utils.unpack_fields` did not work. + ### Version 0.1.3 - Fatal bug fix: `jeb_utils.jeb_utils.validate_topic_name` has not returned `True` if the topic name is valid, it returned `None` (falsy). Now it returns `True` if the topic name is valid. diff --git a/pyproject.toml b/pyproject.toml index 6c5477b..a4e2cb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "jeb-utils" -version = "0.1.3" +version = "0.1.4" description = "Common utils for JEB client and server." dependencies = ["cryptography"] license = "MIT" \ No newline at end of file diff --git a/src/jeb_utils/jebp_utils.py b/src/jeb_utils/jebp_utils.py index 2f8ec66..fc7b34f 100644 --- a/src/jeb_utils/jebp_utils.py +++ b/src/jeb_utils/jebp_utils.py @@ -107,24 +107,24 @@ def pack_fields(*fields: bytes) -> bytes: result += field_length_length + field_length + field return result -def unpack_fields(packed: bytes) -> Sequence[bytes]: +def unpack_fields(raw: bytes) -> Sequence[bytes]: ''' Unpacks the field from a bytestring. - :param packed: The packed fields - :type packed: bytes + :param raw: The packed fields + :type raw: bytes :return: The unpacked fields :rtype: Sequence[bytes] ''' packed = [] - buffer = io.BytesIO(packed) - while buffer.tell() < len(packed): + buffer = io.BytesIO(raw) + while buffer.tell() < len(raw): try: field_length_length = int.from_bytes(buffer.read(1)) field_length = int.from_bytes(buffer.read(field_length_length)) field = buffer.read(field_length) - packed += (field,) + packed.append(field) except: pass return packed \ No newline at end of file