Fix early cast to input from 932ed9e causing error on Peer

This commit is contained in:
Lonami Exo 2017-12-29 22:07:16 +01:00
parent d2121c76cb
commit cbf6306599

View File

@ -336,9 +336,11 @@ class Session:
Raises ValueError if it cannot be found. Raises ValueError if it cannot be found.
""" """
if isinstance(key, TLObject): if isinstance(key, TLObject):
key = utils.get_input_peer(key) try:
if type(key).SUBCLASS_OF_ID == 0xc91c90b6: # crc32(b'InputPeer') # Try to early return if this key can be casted as input peer
return key return utils.get_input_peer(key)
except TypeError:
# Otherwise, get the ID of the peer
key = utils.get_peer_id(key) key = utils.get_peer_id(key)
c = self._conn.cursor() c = self._conn.cursor()