whois/whois.py
changeset 163 faaa3ce1af3e
parent 160 c385321ec3e4
parent 162 93f6f3021941
child 177 7030835bcf5e
--- a/whois/whois.py	Mon Feb 05 14:43:20 2018 -0500
+++ b/whois/whois.py	Mon Feb 05 19:47:43 2018 +0000
@@ -97,34 +97,31 @@
         there for contact details
         """
         response = b''
-        try:
-            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-            s.settimeout(10)
-            s.connect((hostname, 43))
+        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        s.settimeout(10)
+        s.connect((hostname, 43))
 
-            try:
-                query = query.decode('utf-8')
-            except UnicodeEncodeError:
-                pass  # Already Unicode (python2's error)
-            except AttributeError:
-                pass  # Already Unicode (python3's error)
+        try:
+            query = query.decode('utf-8')
+        except UnicodeEncodeError:
+            pass  # Already Unicode (python2's error)
+        except AttributeError:
+            pass  # Already Unicode (python3's error)
 
-            if hostname == NICClient.DENICHOST:
-                query_bytes = "-T dn,ace -C UTF-8 " + query
-            elif hostname.endswith(NICClient.QNICHOST_TAIL) and many_results:
-                query_bytes = '=' + query
-            else:
-                query_bytes = query
-            s.send(bytes(query_bytes,'utf-8') + b"\r\n")
-            # recv returns bytes
-            while True:
-                d = s.recv(4096)
-                response += d
-                if not d:
-                    break
-            s.close()
-        except socket.error as socketerror:
-            print('Socket Error:', socketerror)
+        if hostname == NICClient.DENICHOST:
+            query_bytes = "-T dn,ace -C UTF-8 " + query
+        elif hostname.endswith(NICClient.QNICHOST_TAIL) and many_results:
+            query_bytes = '=' + query
+        else:
+            query_bytes = query
+        s.send(bytes(query_bytes,'utf-8') + b"\r\n")
+        # recv returns bytes
+        while True:
+            d = s.recv(4096)
+            response += d
+            if not d:
+                break
+        s.close()
 
         nhost = None
         response = response.decode('utf-8', 'replace')