From 3eaba9d2f4cb7ee7ec24a3ebf0116dfbbe00b955 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 25 Dec 2017 11:47:08 +0100 Subject: [PATCH] Fix deserialization for bare Vectors --- pyrogram/api/core/primitives/vector.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pyrogram/api/core/primitives/vector.py b/pyrogram/api/core/primitives/vector.py index 60890ae6..49db28ec 100644 --- a/pyrogram/api/core/primitives/vector.py +++ b/pyrogram/api/core/primitives/vector.py @@ -25,11 +25,21 @@ from ..object import Object class Vector(Object): ID = 0x1cb5c415 + # Method added to handle the special case when a query returns a bare Vector (of Ints); + # i.e., RpcResult body starts with 0x1cb5c415 (Vector Id) - e.g., messages.GetMessagesViews. + @staticmethod + def _read(b: BytesIO) -> Object or int: + try: + return Object.read(b) + except KeyError: + b.seek(-4, 1) + return Int.read(b) + @staticmethod def read(b: BytesIO, t: Object = None) -> list: return [ t.read(b) if t - else Object.read(b) + else Vector._read(b) for _ in range(Int.read(b)) ]