URL: https://github.com/freeipa/freeipa/pull/375
Author: tiran
 Title: #375: Fix used before assignment bug in host_port_open()
Action: opened

PR body:
"""
Detected by most recent pylint under Python 3.5.

Signed-off-by: Christian Heimes <chei...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/375/head:pr375
git checkout pr375
From fb2e0fbb139a2f57b328114f0bbf32e95c2a58ca Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Thu, 5 Jan 2017 19:51:52 +0100
Subject: [PATCH] Fix used before assignment bug in host_port_open()

Detected by most recent pylint under Python 3.5.

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 ipapython/ipautil.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index f061e79..fca8af9 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -885,6 +885,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)
 
@@ -912,9 +913,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
 
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to