From 7ffe2b313047713c643f1859cb6c34271b39b19a Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Wed, 10 May 2017 03:05:14 +1000 Subject: [PATCH] TcpClient: Combine two identical function calls into one --- telethon/network/tcp_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/telethon/network/tcp_client.py b/telethon/network/tcp_client.py index e8e03a71..5545ecdf 100755 --- a/telethon/network/tcp_client.py +++ b/telethon/network/tcp_client.py @@ -11,6 +11,7 @@ from telethon.utils import BinaryWriter class TcpClient: def __init__(self, proxy=None): self.connected = False + if proxy: try: import socks @@ -20,8 +21,9 @@ class TcpClient: print("Can't import PySocks, fallback to vanilla socket. " "Proxy settings are ignored. " "Try to install PySocks via pip") - self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - else: + proxy = None + + if not proxy: self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Support for multi-threading advantages and safety