# HG changeset patch # User Evgeni Kunev # Date 1408098684 -10800 # Node ID f9da616f15cf97e620ecd1b32349ab63ce352cec # Parent 8c4c05eb65f4dec16070f1e83081d23a84fc15d5 Pass all domains through encode('idna') in NICClient This makes sure that non-ascii domains will be properly encoded in punnycode before sending the whois query to the server. diff -r 8c4c05eb65f4 -r f9da616f15cf whois/whois.py --- a/whois/whois.py Fri Aug 15 11:59:58 2014 +0300 +++ b/whois/whois.py Fri Aug 15 13:31:24 2014 +0300 @@ -127,12 +127,15 @@ """send takes bytes as an input """ queryBytes = None + if type(query) is not unicode: + query = query.decode('utf-8') + if (hostname == NICClient.DENICHOST): # print 'the domain is in NIC DENIC' - queryBytes = ("-T dn,ace -C UTF-8 " + query + "\r\n").encode() + queryBytes = ("-T dn,ace -C UTF-8 " + query + "\r\n").encode('idna') # print 'queryBytes:', queryBytes else: - queryBytes = (query + "\r\n").encode() + queryBytes = (query + "\r\n").encode('idna') s.send(queryBytes) """recv returns bytes """