Fixed a bug
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user