From 428cbf56a6b0b77dbe1f16aa301c9d5ecb02c058 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 25 Sep 2021 10:12:12 +0200 Subject: [PATCH] Read integers first when size matches --- pyrogram/raw/core/primitives/vector.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pyrogram/raw/core/primitives/vector.py b/pyrogram/raw/core/primitives/vector.py index c51bbaf3..48b2eed9 100644 --- a/pyrogram/raw/core/primitives/vector.py +++ b/pyrogram/raw/core/primitives/vector.py @@ -31,21 +31,19 @@ class Vector(bytes, TLObject): # i.e., RpcResult body starts with 0x1cb5c415 (Vector Id) - e.g., messages.GetMessagesViews. @staticmethod def read_bare(b: BytesIO, size: int) -> Union[int, Any]: - try: - return TLObject.read(b) - except KeyError: - b.seek(-4, 1) + if size == 4: + return Int.read(b) + + if size == 8: + return Long.read(b) - if size == 4: - return Int.read(b) - else: - return Long.read(b) + return TLObject.read(b) @classmethod def read(cls, data: BytesIO, t: Any = None, *args: Any) -> List: count = Int.read(data) left = len(data.read()) - size = (left // count) if count else 0 + size = (left / count) if count else 0 data.seek(-left, 1) return List(