Fix used before assignment bug in host_port_open()

Detected by most recent pylint under Python 3.5.

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Christian Heimes 2017-01-05 19:51:52 +01:00 committed by Martin Basti
parent fb7c111ac1
commit deaad95247

View File

@ -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