mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Stop showing "data left after" warning
This commit is contained in:
parent
410518aa65
commit
59f6b75391
|
@ -42,5 +42,8 @@ class MTProtoPlainSender:
|
|||
assert reader.read_long() == 0 # auth_key_id
|
||||
assert reader.read_long() > msg_id # msg_id
|
||||
assert reader.read_int() # length
|
||||
# No need to read "length" bytes first, just read the object
|
||||
|
||||
# We could read length bytes and use those in a new reader to read
|
||||
# the next TLObject without including the padding, but since the
|
||||
# reader isn't used for anything else after this, it's unnecessary.
|
||||
return reader.tgread_object()
|
||||
|
|
|
@ -121,6 +121,10 @@ class MTProtoState:
|
|||
remote_msg_id = reader.read_long()
|
||||
remote_sequence = reader.read_int()
|
||||
reader.read_int() # msg_len for the inner object, padding ignored
|
||||
|
||||
# We could read msg_len bytes and use those in a new reader to read
|
||||
# the next TLObject without including the padding, but since the
|
||||
# reader isn't used for anything else after this, it's unnecessary.
|
||||
obj = reader.tgread_object()
|
||||
|
||||
return TLMessage(remote_msg_id, remote_sequence, obj)
|
||||
|
|
|
@ -36,10 +36,7 @@ class MessageContainer(TLObject):
|
|||
seq_no = reader.read_int()
|
||||
length = reader.read_int()
|
||||
before = reader.tell_position()
|
||||
obj = reader.tgread_object()
|
||||
obj = reader.tgread_object() # May over-read e.g. RpcResult
|
||||
reader.set_position(before + length)
|
||||
messages.append(TLMessage(msg_id, seq_no, obj))
|
||||
if reader.tell_position() != before + length:
|
||||
reader.set_position(before)
|
||||
__log__.warning('Data left after TLObject {}: {!r}'
|
||||
.format(obj, reader.read(length)))
|
||||
return MessageContainer(messages)
|
||||
|
|
|
@ -21,6 +21,9 @@ class RpcResult(TLObject):
|
|||
return RpcResult(msg_id, GzipPacked.from_reader(reader).data, None)
|
||||
|
||||
reader.seek(-4)
|
||||
# This reader.read() will read more than necessary, but it's okay.
|
||||
# We could make use of MessageContainer's length here, but since
|
||||
# it's not necessary we don't need to care about it.
|
||||
return RpcResult(msg_id, reader.read(), None)
|
||||
|
||||
def to_dict(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user