whois/whois.py
changeset 34 f9da616f15cf
parent 32 5f851e9c196a
child 36 af839b9c0ed1
equal deleted inserted replaced
33:8c4c05eb65f4 34:f9da616f15cf
   125         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   125         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   126         s.connect((hostname, 43))
   126         s.connect((hostname, 43))
   127         """send takes bytes as an input
   127         """send takes bytes as an input
   128         """
   128         """
   129         queryBytes = None
   129         queryBytes = None
       
   130         if type(query) is not unicode:
       
   131             query = query.decode('utf-8')
       
   132 
   130         if (hostname == NICClient.DENICHOST):
   133         if (hostname == NICClient.DENICHOST):
   131             # print 'the domain is in NIC DENIC'
   134             # print 'the domain is in NIC DENIC'
   132             queryBytes = ("-T dn,ace -C UTF-8 " + query + "\r\n").encode()
   135             queryBytes = ("-T dn,ace -C UTF-8 " + query + "\r\n").encode('idna')
   133             # print 'queryBytes:', queryBytes
   136             # print 'queryBytes:', queryBytes
   134         else:
   137         else:
   135             queryBytes = (query + "\r\n").encode()
   138             queryBytes = (query + "\r\n").encode('idna')
   136         s.send(queryBytes)
   139         s.send(queryBytes)
   137         """recv returns bytes
   140         """recv returns bytes
   138         """
   141         """
   139         # print s
   142         # print s
   140         response = b''
   143         response = b''