Use 'is' in comparison to None

... instead of == or != .
This commit is contained in:
Takashi Kajinami 2025-06-08 22:47:17 +09:00
parent b9194bf175
commit 992a2d1793
2 changed files with 10 additions and 10 deletions

View File

@ -367,7 +367,7 @@ class WebSocketProxy(websockifyserver.WebSockifyServer):
else:
dst_string = "%s:%s" % (self.target_host, self.target_port)
if self.listen_fd != None:
if self.listen_fd is not None:
src_string = "inetd"
else:
src_string = "%s:%s" % (self.listen_host, self.listen_port)
@ -392,11 +392,11 @@ class WebSocketProxy(websockifyserver.WebSockifyServer):
if self.wrap_cmd and self.cmd:
ret = self.cmd.poll()
if ret != None:
if ret is not None:
self.vmsg("Wrapped command exited (or daemon). Returned %s" % ret)
self.cmd = None
if self.wrap_cmd and self.cmd == None:
if self.wrap_cmd and self.cmd is None:
# Response to wrapped command being gone
if self.wrap_mode == "ignore":
pass
@ -708,7 +708,7 @@ def websockify_init():
except ValueError:
parser.error("Error parsing target port")
if len(args) > 0 and opts.wrap_cmd == None:
if len(args) > 0 and opts.wrap_cmd is None:
parser.error("Too many arguments")
if opts.token_plugin is not None:

View File

@ -22,7 +22,7 @@ for mod, msg in [('ssl', 'TLS/SSL/wss is disabled'),
try:
globals()[mod] = __import__(mod)
except ImportError:
globals()[mod] = None
globals()[mod] is None
print("WARNING: no '%s' module, %s" % (mod, msg))
if sys.platform == 'win32':
@ -405,9 +405,9 @@ class WebSockifyServer():
# Show configuration
self.msg("WebSocket server settings:")
if self.listen_fd != None:
if self.listen_fd is not None:
self.msg(" - Listen for inetd connections")
elif self.unix_listen != None:
elif self.unix_listen is not None:
self.msg(" - Listen on unix socket %s", self.unix_listen)
else:
self.msg(" - Listen on %s:%s",
@ -741,9 +741,9 @@ class WebSockifyServer():
"""
try:
if self.listen_fd != None:
if self.listen_fd is not None:
lsock = socket.fromfd(self.listen_fd, socket.AF_INET, socket.SOCK_STREAM)
elif self.unix_listen != None:
elif self.unix_listen is not None:
lsock = self.socket(host=None,
unix_socket=self.unix_listen,
unix_socket_mode=self.unix_listen_mode,
@ -819,7 +819,7 @@ class WebSockifyServer():
if lsock in ready:
startsock, address = lsock.accept()
# Unix Socket will not report address (empty string), but address[0] is logged a bunch
if self.unix_listen != None:
if self.unix_listen is not None:
address = [self.unix_listen]
else:
continue