Commit 5af8c102 authored by Jason Madden's avatar Jason Madden

Fixes for the ares resolver.

parent 57c4a093
...@@ -222,7 +222,7 @@ def getfqdn(name=''): ...@@ -222,7 +222,7 @@ def getfqdn(name=''):
else: else:
aliases.insert(0, hostname) aliases.insert(0, hostname)
for name in aliases: for name in aliases:
if '.' in name: if b'.' in name:
break break
else: else:
name = hostname name = hostname
......
...@@ -682,6 +682,8 @@ class WSGIServer(StreamServer): ...@@ -682,6 +682,8 @@ class WSGIServer(StreamServer):
name = socket.getfqdn(address[0]) name = socket.getfqdn(address[0])
except socket.error: except socket.error:
name = str(address[0]) name = str(address[0])
if PY3 and not isinstance(name, str):
name = name.decode('ascii')
self.environ['SERVER_NAME'] = name self.environ['SERVER_NAME'] = name
self.environ.setdefault('SERVER_PORT', str(address[1])) self.environ.setdefault('SERVER_PORT', str(address[1]))
else: else:
......
...@@ -208,6 +208,8 @@ class Resolver(object): ...@@ -208,6 +208,8 @@ class Resolver(object):
if _ip_address == ip_address: if _ip_address == ip_address:
raise raise
waiter.clear() waiter.clear()
if isinstance(_ip_address, text_type):
_ip_address = _ip_address.encode('ascii')
self.ares.gethostbyaddr(waiter, _ip_address) self.ares.gethostbyaddr(waiter, _ip_address)
return waiter.get() return waiter.get()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment