summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2017-01-05 19:51:52 +0100
committerMartin Basti <mbasti@redhat.com>2017-01-06 10:07:33 +0100
commitdeaad95247fa9624bef0108bf3813f358fb17ee5 (patch)
treeff3b22e2c199eda14813577d57d06ef7151636b7 /ipapython
parentfb7c111ac13510609e2cba14ecf88cd2ed291a4b (diff)
downloadfreeipa-deaad95247fa9624bef0108bf3813f358fb17ee5.tar.gz
freeipa-deaad95247fa9624bef0108bf3813f358fb17ee5.tar.xz
freeipa-deaad95247fa9624bef0108bf3813f358fb17ee5.zip
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>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipautil.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 408ca3fb0..e3e4611b8 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