--- a/whois/whois.py Wed Mar 16 15:08:15 2016 +0100
+++ b/whois/whois.py Wed Mar 16 15:18:36 2016 +0100
@@ -24,13 +24,20 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
+from __future__ import print_function
+from __future__ import unicode_literals
+from __future__ import division
+from __future__ import absolute_import
+from future import standard_library
+standard_library.install_aliases()
+from builtins import *
+from builtins import object
import re
import sys
import socket
import optparse
-
class NICClient(object):
ABUSEHOST = "whois.abuse.net"
@@ -90,7 +97,7 @@
s.connect((hostname, 43))
# end takes bytes as an input
queryBytes = None
- if type(query) is not unicode:
+ if type(query) is not str:
query = query.decode('utf-8')
if hostname == NICClient.DENICHOST:
@@ -109,12 +116,12 @@
break
s.close()
except socket.error as socketerror:
- print 'Socket Error:', socketerror
+ print('Socket Error:', socketerror)
return ''
else:
nhost = None
response = response.decode('utf-8')
- if 'with "=xxx"' in response:
+ if b'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, hostname, query)
@@ -122,10 +129,11 @@
response += self.whois(query, nhost, 0)
return response
+
def choose_server(self, domain):
"""Choose initial lookup NIC host"""
- if type(domain) is not unicode:
- domain = domain.decode('utf-8').encode('idna')
+ if type(domain) is not str:
+ domain = domain.decode('utf-8').encode('idna').decode('utf-8')
if domain.endswith("-NORID"):
return NICClient.NORIDHOST
pos = domain.rfind('.')
@@ -238,4 +246,4 @@
options, args = parse_command_line(sys.argv)
if options.b_quicklookup:
flags = flags | NICClient.WHOIS_QUICK
- print nic_client.whois_lookup(options.__dict__, args[1], flags)
+ print(nic_client.whois_lookup(options.__dict__, args[1], flags))