diff -r 54de7f516385 -r 93f6f3021941 whois/whois.py --- a/whois/whois.py Thu Jan 11 23:49:59 2018 +0100 +++ b/whois/whois.py Sat Jan 27 00:34:23 2018 +0100 @@ -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')