Actually fix reading vectors of bare longs
This commit is contained in:
parent
c3953c18ca
commit
acd92b100b
@ -30,11 +30,7 @@ class Vector(bytes, TLObject):
|
|||||||
# Method added to handle the special case when a query returns a bare Vector (of Ints);
|
# 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.
|
# i.e., RpcResult body starts with 0x1cb5c415 (Vector Id) - e.g., messages.GetMessagesViews.
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read_bare(b: BytesIO, n: int) -> Union[int, Any]:
|
def read_bare(b: BytesIO, size: int) -> Union[int, Any]:
|
||||||
left = len(b.read())
|
|
||||||
size = left // n
|
|
||||||
b.seek(-left, 1)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return TLObject.read(b)
|
return TLObject.read(b)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -48,10 +44,13 @@ class Vector(bytes, TLObject):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def read(cls, data: BytesIO, t: Any = None, *args: Any) -> List:
|
def read(cls, data: BytesIO, t: Any = None, *args: Any) -> List:
|
||||||
count = Int.read(data)
|
count = Int.read(data)
|
||||||
|
left = len(data.read())
|
||||||
|
size = left // count
|
||||||
|
data.seek(-left, 1)
|
||||||
|
|
||||||
return List(
|
return List(
|
||||||
t.read(data) if t
|
t.read(data) if t
|
||||||
else Vector.read_bare(data, count)
|
else Vector.read_bare(data, size)
|
||||||
for _ in range(count)
|
for _ in range(count)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user