Commit c99bf9f1 authored by Denis Bilenko's avatar Denis Bilenko

rename gevent.evdns to gevent.dns

--HG--
rename : gevent/evdns.py => gevent/dns.py
parent 0ea8c9fd
...@@ -774,7 +774,7 @@ def wrap_ssl000(sock, keyfile=None, certfile=None): ...@@ -774,7 +774,7 @@ def wrap_ssl000(sock, keyfile=None, certfile=None):
return ssl_sock return ssl_sock
try: try:
from gevent.evdns import resolve_ipv4, resolve_ipv6 from gevent.dns import resolve_ipv4, resolve_ipv6
except: except:
import traceback import traceback
traceback.print_exc() traceback.print_exc()
...@@ -783,11 +783,11 @@ except: ...@@ -783,11 +783,11 @@ except:
else: else:
def gethostbyname(hostname): def gethostbyname(hostname):
""":func:`socket.gethostbyname` implemented using :mod:`evdns`. """:func:`socket.gethostbyname` implemented using :mod:`dns`.
Differs in the following ways: Differs in the following ways:
* raises :class:`DNSError` (a subclass of :class:`socket.gaierror`) with evdns error * raises :class:`DNSError` (a subclass of :class:`socket.gaierror`) with dns error
codes instead of standard socket error codes codes instead of standard socket error codes
* does not support ``/etc/hosts`` but calls the original :func:`socket.gethostbyname` * does not support ``/etc/hosts`` but calls the original :func:`socket.gethostbyname`
if *hostname* has no dots if *hostname* has no dots
...@@ -807,7 +807,7 @@ else: ...@@ -807,7 +807,7 @@ else:
def getaddrinfo(host, port, *args, **kwargs): def getaddrinfo(host, port, *args, **kwargs):
"""*Some* approximation of :func:`socket.getaddrinfo` implemented using :mod:`evdns`. """*Some* approximation of :func:`socket.getaddrinfo` implemented using :mod:`dns`.
If *host* is not a string, does not has any dots or is a numeric IP address, then If *host* is not a string, does not has any dots or is a numeric IP address, then
the standard :func:`socket.getaddrinfo` is called. the standard :func:`socket.getaddrinfo` is called.
...@@ -817,7 +817,7 @@ else: ...@@ -817,7 +817,7 @@ else:
Differs in the following ways: Differs in the following ways:
* raises :class:`DNSError` (a subclass of :class:`gaierror`) with evdns error * raises :class:`DNSError` (a subclass of :class:`gaierror`) with libevent-dns error
codes instead of standard socket error codes codes instead of standard socket error codes
* IPv6 support is untested. * IPv6 support is untested.
* AF_UNSPEC only tries IPv4 * AF_UNSPEC only tries IPv4
...@@ -826,7 +826,7 @@ else: ...@@ -826,7 +826,7 @@ else:
* *flags* argument is ignored * *flags* argument is ignored
Additionally, supports *evdns_flags* keyword arguments (default ``0``) that is passed Additionally, supports *evdns_flags* keyword arguments (default ``0``) that is passed
to :mod:`evdns` functions. to :mod:`dns` functions.
""" """
family, socktype, proto, _flags = args + (None, ) * (4 - len(args)) family, socktype, proto, _flags = args + (None, ) * (4 - len(args))
if not isinstance(host, str) or '.' not in host or _ip4_re.match(host): if not isinstance(host, str) or '.' not in host or _ip4_re.match(host):
......
#!/usr/bin/python #!/usr/bin/python
import greentest import greentest
from gevent import evdns from gevent import dns
from gevent import core from gevent import core
from gevent import socket from gevent import socket
from gevent.dns import DNSError
funcs = [evdns.resolve_ipv4, evdns.resolve_ipv6, funcs = [dns.resolve_ipv4, dns.resolve_ipv6,
evdns.resolve_reverse, evdns.resolve_reverse_ipv6] dns.resolve_reverse, dns.resolve_reverse_ipv6]
class TestNoSwitch(greentest.TestCase): class TestNoSwitch(greentest.TestCase):
...@@ -30,10 +31,10 @@ class TestSwitch(greentest.TestCase): ...@@ -30,10 +31,10 @@ class TestSwitch(greentest.TestCase):
switch_expected = True switch_expected = True
def test_empty_string(self): def test_empty_string(self):
self.assertRaises(evdns.DNSError, evdns.resolve_ipv4, '') self.assertRaises(DNSError, dns.resolve_ipv4, '')
self.assertRaises(evdns.DNSError, evdns.resolve_ipv6, '') self.assertRaises(DNSError, dns.resolve_ipv6, '')
self.assertRaises(evdns.DNSError, evdns.resolve_reverse, '') self.assertRaises(DNSError, dns.resolve_reverse, '')
self.assertRaises(evdns.DNSError, evdns.resolve_reverse_ipv6, '') self.assertRaises(DNSError, dns.resolve_reverse_ipv6, '')
if __name__ == '__main__': if __name__ == '__main__':
......
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