From cbf6306599115ad7a130eee07a8bf7106caef683 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 29 Dec 2017 22:07:16 +0100 Subject: [PATCH] Fix early cast to input from 932ed9e causing error on Peer --- telethon/tl/session.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/telethon/tl/session.py b/telethon/tl/session.py index 8c2850bf..3fa13d23 100644 --- a/telethon/tl/session.py +++ b/telethon/tl/session.py @@ -336,10 +336,12 @@ class Session: Raises ValueError if it cannot be found. """ if isinstance(key, TLObject): - key = utils.get_input_peer(key) - if type(key).SUBCLASS_OF_ID == 0xc91c90b6: # crc32(b'InputPeer') - return key - key = utils.get_peer_id(key) + try: + # Try to early return if this key can be casted as input peer + return utils.get_input_peer(key) + except TypeError: + # Otherwise, get the ID of the peer + key = utils.get_peer_id(key) c = self._conn.cursor() if isinstance(key, str):