From 0ef32a7d78e0296102a3a97baba229b74f34f159 Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Fri, 19 May 2017 15:48:01 +1000 Subject: [PATCH] Fix syntax of exception throwing here and there --- telethon/interactive_telegram_client.py | 2 +- telethon/network/tcp_client.py | 4 ++-- telethon/telegram_client.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/telethon/interactive_telegram_client.py b/telethon/interactive_telegram_client.py index bfa28a73..4393cfa1 100644 --- a/telethon/interactive_telegram_client.py +++ b/telethon/interactive_telegram_client.py @@ -64,7 +64,7 @@ class InteractiveTelegramClient(TelegramClient): 'Two step verification is enabled. Please enter your password: ') code_ok = self.sign_in(password=pw) else: - raise e + raise def run(self): # Listen for updates diff --git a/telethon/network/tcp_client.py b/telethon/network/tcp_client.py index 5545ecdf..bb9bc2e9 100755 --- a/telethon/network/tcp_client.py +++ b/telethon/network/tcp_client.py @@ -84,7 +84,7 @@ class TcpClient: partial = self.socket.recv(left_count) writer.write(partial) - except BlockingIOError: + except BlockingIOError as error: # There was no data available for us to read. Sleep a bit time.sleep(self.delay) @@ -93,7 +93,7 @@ class TcpClient: time_passed = datetime.now() - start_time if time_passed > timeout: raise TimeoutError( - 'The read operation exceeded the timeout.') + 'The read operation exceeded the timeout.') from error # If everything went fine, return the read bytes return writer.get_bytes() diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 0db78847..320ca5db 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -173,7 +173,7 @@ class TelegramClient: except InvalidDCError as error: if throw_invalid_dc: - raise error + raise self.reconnect_to_dc(error.new_dc) return self.invoke(request, timeout=timeout, throw_invalid_dc=True) @@ -216,7 +216,7 @@ class TelegramClient: print(error) return False else: - raise error + raise elif password: salt = self.invoke(GetPasswordRequest()).current_salt result = self.invoke(