Марк Коренберг added the comment:
Oops.
def serialize(value: int, signed=True) -> bytes:
x = value.to_bytes(-1, 'big', signed=signed)
l = len(x).to_bytes(4, 'big', signed=False)
return l + x
assert len(serialize(0)) == 4 + 0 # see Issue27623
assert len(serialize(120)) == 4 + 1
assert len(serialize(130)) == 4 + 2
assert len(serialize(130), False) == 4 + 1
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27637>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com