whois/whois.py
branchpython3
changeset 71 b181f795cc0d
parent 70 1fe2c20adeba
child 73 644d81a7995b
--- a/whois/whois.py	Sun Feb 07 22:30:17 2016 +0100
+++ b/whois/whois.py	Sun Feb 07 23:29:44 2016 +0100
@@ -39,7 +39,7 @@
 
 
 def enforce_ascii(a):
-    return a if isinstance(a, bytes) else bytes([63 if ord(c) > 127 else ord(c) for c in a])
+    return a if isinstance(a, bytes) else bytes([63 if ord(c) > 127 else ord(c) for c in a]).decode('ascii')
 
 class NICClient(object):
 
@@ -129,11 +129,12 @@
             if flags & NICClient.WHOIS_RECURSE and nhost is None:
                 nhost = self.findwhois_server(response.decode(), hostname, query)
             if nhost is not None:
-                response += self.whois(query, nhost, 0)
+                response += self.whois(query, nhost, 0).encode('utf-8')
             return response.decode()
 
     def choose_server(self, domain):
         """Choose initial lookup NIC host"""
+        print('domain:', domain)
         if type(domain) is not str:
             domain = domain.decode('utf-8').encode('idna').decode('utf-8')
         if domain.endswith("-NORID"):
@@ -171,6 +172,7 @@
             )
         elif self.use_qnichost:
             nichost = self.choose_server(query_arg)
+            print('nichost:', nichost)
             if nichost is not None:
                 result = self.whois(query_arg, nichost, flags)
             else: