Skip to content

Commit d2c40b8

Browse files
committed
Upgrade Python syntax with pyupgrade
1 parent 1e9d869 commit d2c40b8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

socks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(self, msg, socket_err=None):
114114
self.socket_err = socket_err
115115

116116
if socket_err:
117-
self.msg += ": {0}".format(socket_err)
117+
self.msg += ": {}".format(socket_err)
118118

119119
def __str__(self):
120120
return self.msg
@@ -583,7 +583,7 @@ def _SOCKS5_request(self, conn, cmd, dst):
583583
if status != 0x00:
584584
# Connection failed: server returned an error
585585
error = SOCKS5_ERRORS.get(status, "Unknown error")
586-
raise SOCKS5Error("{0:#04x}: {1}".format(status, error))
586+
raise SOCKS5Error("{:#04x}: {}".format(status, error))
587587

588588
# Get the bound address/port
589589
bnd = self._read_SOCKS5_address(reader)
@@ -701,7 +701,7 @@ def _negotiate_SOCKS4(self, dest_addr, dest_port):
701701
if status != 0x5A:
702702
# Connection failed: server returned an error
703703
error = SOCKS4_ERRORS.get(status, "Unknown error")
704-
raise SOCKS4Error("{0:#04x}: {1}".format(status, error))
704+
raise SOCKS4Error("{:#04x}: {}".format(status, error))
705705

706706
# Get the bound address/port
707707
self.proxy_sockname = (socket.inet_ntoa(resp[4:]),
@@ -761,7 +761,7 @@ def _negotiate_HTTP(self, dest_addr, dest_port):
761761
"HTTP proxy server did not return a valid HTTP status")
762762

763763
if status_code != 200:
764-
error = "{0}: {1}".format(status_code, status_msg)
764+
error = "{}: {}".format(status_code, status_msg)
765765
if status_code in (400, 403, 405):
766766
# It's likely that the HTTP proxy server does not support the
767767
# CONNECT tunneling method
@@ -844,10 +844,10 @@ def connect(self, dest_pair, catch_errors=None):
844844
self.close()
845845
if not catch_errors:
846846
proxy_addr, proxy_port = proxy_addr
847-
proxy_server = "{0}:{1}".format(proxy_addr, proxy_port)
847+
proxy_server = "{}:{}".format(proxy_addr, proxy_port)
848848
printable_type = PRINTABLE_PROXY_TYPES[proxy_type]
849849

850-
msg = "Error connecting to {0} proxy {1}".format(printable_type,
850+
msg = "Error connecting to {} proxy {}".format(printable_type,
851851
proxy_server)
852852
log.debug("%s due to: %s", msg, error)
853853
raise ProxyConnectionError(msg, error)

0 commit comments

Comments
 (0)