removed to ascii function and treat as utf-8
authorRichard Penman
Wed, 16 Mar 2016 15:08:15 +0100
changeset 80 fa9650e9ec23
parent 65 50b5966b5566
child 81 359baebcf0e8
removed to ascii function and treat as utf-8
setup.py
whois/whois.py
--- a/setup.py	Mon Sep 14 15:19:11 2015 +0100
+++ b/setup.py	Wed Mar 16 15:08:15 2016 +0100
@@ -1,7 +1,7 @@
 import sys, os
 import setuptools
 
-version = '0.5.1'
+version = '0.5.2'
 
 setuptools.setup(
     name='python-whois',
--- a/whois/whois.py	Mon Sep 14 15:19:11 2015 +0100
+++ b/whois/whois.py	Wed Mar 16 15:08:15 2016 +0100
@@ -30,18 +30,6 @@
 import optparse
 
 
-def enforce_ascii(a):
-    if isinstance(a, str) or isinstance(a, unicode):
-        r = ""
-        for i in a:
-            if ord(i) >= 128:
-                r += "?"
-            else:
-                r += i
-        return r
-    else:
-        return a
-
 
 class NICClient(object):
 
@@ -125,14 +113,14 @@
             return ''
         else:
             nhost = None
-            response = enforce_ascii(response)
+            response = response.decode('utf-8')
             if 'with "=xxx"' in response:
                 return self.whois(query, hostname, flags, True)
             if flags & NICClient.WHOIS_RECURSE and nhost is None:
-                nhost = self.findwhois_server(response.decode(), hostname, query)
+                nhost = self.findwhois_server(response, hostname, query)
             if nhost is not None:
                 response += self.whois(query, nhost, 0)
-            return response.decode()
+            return response
 
     def choose_server(self, domain):
         """Choose initial lookup NIC host"""