File tree Expand file tree Collapse file tree
pyrogram/raw/core/primitives Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from io import BytesIO
2020from typing import cast , Union , Any
2121
22- from .int import Int
22+ from .int import Int , Long
2323from ..list import List
2424from ..tl_object import TLObject
2525
@@ -30,19 +30,29 @@ class Vector(bytes, TLObject):
3030 # Method added to handle the special case when a query returns a bare Vector (of Ints);
3131 # i.e., RpcResult body starts with 0x1cb5c415 (Vector Id) - e.g., messages.GetMessagesViews.
3232 @staticmethod
33- def _read (b : BytesIO ) -> Union [int , Any ]:
33+ def read_bare (b : BytesIO , n : int ) -> Union [int , Any ]:
34+ left = len (b .read ())
35+ size = left // n
36+ b .seek (- left , 1 )
37+
3438 try :
3539 return TLObject .read (b )
36- except ValueError :
40+ except KeyError :
3741 b .seek (- 4 , 1 )
38- return Int .read (b )
42+
43+ if size == 4 :
44+ return Int .read (b )
45+ else :
46+ return Long .read (b )
3947
4048 @classmethod
4149 def read (cls , data : BytesIO , t : Any = None , * args : Any ) -> List :
50+ count = Int .read (data )
51+
4252 return List (
4353 t .read (data ) if t
44- else Vector ._read (data )
45- for _ in range (Int . read ( data ) )
54+ else Vector .read_bare (data , count )
55+ for _ in range (count )
4656 )
4757
4858 def __new__ (cls , value : list , t : Any = None ) -> bytes : # type: ignore
You can’t perform that action at this time.
0 commit comments