From deaad95247fa9624bef0108bf3813f358fb17ee5 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Jan 06 2017 09:07:33 +0000 Subject: Fix used before assignment bug in host_port_open() Detected by most recent pylint under Python 3.5. Signed-off-by: Christian Heimes Reviewed-By: Martin Basti --- diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 408ca3f..e3e4611 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -941,6 +941,7 @@ def host_port_open(host, port, socket_type=socket.SOCK_STREAM, # port has to be open on ALL resolved IPs for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket_type): af, socktype, proto, _canonname, sa = res + s = None try: s = socket.socket(af, socktype, proto) @@ -968,9 +969,8 @@ def host_port_open(host, port, socket_type=socket.SOCK_STREAM, else: root_logger.error(msg) finally: - if s: + if s is not None: s.close() - s = None return port_open