Skip to content

Commit 3eaba9d

Browse files
committed
Fix deserialization for bare Vectors
1 parent 7b6d717 commit 3eaba9d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pyrogram/api/core/primitives/vector.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,21 @@
2525
class Vector(Object):
2626
ID = 0x1cb5c415
2727

28+
# Method added to handle the special case when a query returns a bare Vector (of Ints);
29+
# i.e., RpcResult body starts with 0x1cb5c415 (Vector Id) - e.g., messages.GetMessagesViews.
30+
@staticmethod
31+
def _read(b: BytesIO) -> Object or int:
32+
try:
33+
return Object.read(b)
34+
except KeyError:
35+
b.seek(-4, 1)
36+
return Int.read(b)
37+
2838
@staticmethod
2939
def read(b: BytesIO, t: Object = None) -> list:
3040
return [
3141
t.read(b) if t
32-
else Object.read(b)
42+
else Vector._read(b)
3343
for _ in range(Int.read(b))
3444
]
3545

0 commit comments

Comments
 (0)