Fixed a bug

This commit is contained in:
2026-02-22 21:49:14 +01:00
parent 2c23f59f7c
commit baa58ff831
3 changed files with 10 additions and 7 deletions
+3
View File
@@ -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.
+1 -1
View File
@@ -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"
+6 -6
View File
@@ -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