DeSerializing Bug Fixes

Git-Origin-Commit-Id: c4c275ab
Git-Origin-Commit-Id: dd3f2e51
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
AmarnathCJD 2024-01-19 15:22:48 +01:00 committed by wulan17
parent 73922b95a7
commit b1358c334d
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -19,6 +19,7 @@
from io import BytesIO from io import BytesIO
from typing import cast, Union, Any from typing import cast, Union, Any
from .bool import BoolFalse, BoolTrue, Bool
from .int import Int, Long from .int import Int, Long
from ..list import List from ..list import List
from ..tl_object import TLObject from ..tl_object import TLObject
@ -32,7 +33,22 @@ class Vector(bytes, TLObject):
@staticmethod @staticmethod
def read_bare(b: BytesIO, size: int) -> Union[int, Any]: def read_bare(b: BytesIO, size: int) -> Union[int, Any]:
if size == 4: if size == 4:
return Int.read(b) # cek
e = int.from_bytes(
b.read(4),
"little"
)
# bak
b.seek(-4, 1)
# cond
if e in [
BoolFalse.ID,
BoolTrue.ID,
]:
return Bool.read(b)
# not
else:
return Int.read(b)
if size == 8: if size == 8:
return Long.read(b) return Long.read(b)