mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Remove critical code from assert statements
This commit is contained in:
parent
7efa53fedf
commit
f4b9c9d6d4
|
@ -16,10 +16,14 @@ class Raw(EventBuilder):
|
|||
if not types:
|
||||
self.types = None
|
||||
elif not utils.is_list_like(types):
|
||||
assert isinstance(types, type)
|
||||
if not isinstance(types, type):
|
||||
raise TypeError('Invalid input type given %s', types)
|
||||
|
||||
self.types = types
|
||||
else:
|
||||
assert all(isinstance(x, type) for x in types)
|
||||
if not all(isinstance(x, type) for x in types):
|
||||
raise TypeError('Invalid input types given %s', types)
|
||||
|
||||
self.types = tuple(types)
|
||||
|
||||
async def resolve(self, client):
|
||||
|
|
|
@ -163,7 +163,9 @@ async def do_authentication(sender):
|
|||
if dh_hash != new_nonce_hash:
|
||||
raise SecurityError('Step 3 invalid new nonce hash')
|
||||
|
||||
assert isinstance(dh_gen, DhGenOk), 'Step 3.2 answer was %s' % dh_gen
|
||||
if not isinstance(dh_gen, DhGenOk):
|
||||
raise AssertionError('Step 3.2 answer was %s' % dh_gen)
|
||||
|
||||
return auth_key, time_offset
|
||||
|
||||
|
||||
|
|
|
@ -39,15 +39,18 @@ class MTProtoPlainSender:
|
|||
raise BrokenAuthKeyError()
|
||||
|
||||
with BinaryReader(body) as reader:
|
||||
assert reader.read_long() == 0, 'Bad auth_key_id' # auth_key_id
|
||||
auth_key_id = reader.read_long()
|
||||
assert auth_key_id == 0, 'Bad auth_key_id'
|
||||
|
||||
assert reader.read_long() != 0, 'Bad msg_id' # msg_id
|
||||
msg_id = reader.read_long()
|
||||
assert msg_id != 0, 'Bad msg_id'
|
||||
# ^ We should make sure that the read ``msg_id`` is greater
|
||||
# than our own ``msg_id``. However, under some circumstances
|
||||
# (bad system clock/working behind proxies) this seems to not
|
||||
# be the case, which would cause endless assertion errors.
|
||||
|
||||
assert reader.read_int() > 0, 'Bad length' # length
|
||||
length = reader.read_int()
|
||||
assert length > 0, 'Bad length'
|
||||
# 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.
|
||||
|
|
|
@ -31,7 +31,8 @@ class GzipPacked(TLObject):
|
|||
|
||||
@staticmethod
|
||||
def read(reader):
|
||||
assert reader.read_int(signed=False) == GzipPacked.CONSTRUCTOR_ID
|
||||
constructor = reader.read_int(signed=False)
|
||||
assert constructor == GzipPacked.CONSTRUCTOR_ID
|
||||
return gzip.decompress(reader.tgread_bytes())
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue
Block a user