Fix syntax of exception throwing here and there

This commit is contained in:
Dmitry D. Chernov 2017-05-19 15:48:01 +10:00 committed by Lonami
parent 7f787affc6
commit 0ef32a7d78
3 changed files with 5 additions and 5 deletions

View File

@ -64,7 +64,7 @@ class InteractiveTelegramClient(TelegramClient):
'Two step verification is enabled. Please enter your password: ') 'Two step verification is enabled. Please enter your password: ')
code_ok = self.sign_in(password=pw) code_ok = self.sign_in(password=pw)
else: else:
raise e raise
def run(self): def run(self):
# Listen for updates # Listen for updates

View File

@ -84,7 +84,7 @@ class TcpClient:
partial = self.socket.recv(left_count) partial = self.socket.recv(left_count)
writer.write(partial) writer.write(partial)
except BlockingIOError: except BlockingIOError as error:
# There was no data available for us to read. Sleep a bit # There was no data available for us to read. Sleep a bit
time.sleep(self.delay) time.sleep(self.delay)
@ -93,7 +93,7 @@ class TcpClient:
time_passed = datetime.now() - start_time time_passed = datetime.now() - start_time
if time_passed > timeout: if time_passed > timeout:
raise TimeoutError( raise TimeoutError(
'The read operation exceeded the timeout.') 'The read operation exceeded the timeout.') from error
# If everything went fine, return the read bytes # If everything went fine, return the read bytes
return writer.get_bytes() return writer.get_bytes()

View File

@ -173,7 +173,7 @@ class TelegramClient:
except InvalidDCError as error: except InvalidDCError as error:
if throw_invalid_dc: if throw_invalid_dc:
raise error raise
self.reconnect_to_dc(error.new_dc) self.reconnect_to_dc(error.new_dc)
return self.invoke(request, timeout=timeout, throw_invalid_dc=True) return self.invoke(request, timeout=timeout, throw_invalid_dc=True)
@ -216,7 +216,7 @@ class TelegramClient:
print(error) print(error)
return False return False
else: else:
raise error raise
elif password: elif password:
salt = self.invoke(GetPasswordRequest()).current_salt salt = self.invoke(GetPasswordRequest()).current_salt
result = self.invoke( result = self.invoke(