mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Fix deserialization for bare Vectors
This commit is contained in:
parent
7b6d71753d
commit
3eaba9d2f4
@ -25,11 +25,21 @@ from ..object import Object
|
|||||||
class Vector(Object):
|
class Vector(Object):
|
||||||
ID = 0x1cb5c415
|
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
|
@staticmethod
|
||||||
def read(b: BytesIO, t: Object = None) -> list:
|
def read(b: BytesIO, t: Object = None) -> list:
|
||||||
return [
|
return [
|
||||||
t.read(b) if t
|
t.read(b) if t
|
||||||
else Object.read(b)
|
else Vector._read(b)
|
||||||
for _ in range(Int.read(b))
|
for _ in range(Int.read(b))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user