From 21d004a7bd937d18cc10822d6fa2df6593d1fdab Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 9 Oct 2015 22:01:32 +0300 Subject: [PATCH] TCPConnector processed both IPv4 and IPv6 by default #559 --- CHANGES.txt | 2 ++ aiohttp/connector.py | 2 +- docs/client_reference.rst | 17 +++++++++++++---- tests/test_connector.py | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 66b0b94ad0a..f2f12c348b1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -63,3 +63,5 @@ CHANGES - Add `async with` support for `ClientSession.request()` and family #536 - Ignore message body on 204 and 304 responses #505 + +- `TCPConnector` processed both IPv4 and IPv6 by default #559 diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 91cf510a95a..480864f5a74 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -388,7 +388,7 @@ class TCPConnector(BaseConnector): def __init__(self, *, verify_ssl=True, fingerprint=None, resolve=_marker, use_dns_cache=_marker, - family=socket.AF_INET, ssl_context=None, + family=0, ssl_context=None, **kwargs): super().__init__(**kwargs) diff --git a/docs/client_reference.rst b/docs/client_reference.rst index 131ba82d8e9..206c55bd669 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -619,8 +619,9 @@ BaseConnector TCPConnector ^^^^^^^^^^^^ -.. class:: TCPConnector(*, verify_ssl=True, fingerprint=None, use_dns_cache=False, \ - family=socket.AF_INET, \ +.. class:: TCPConnector(*, verify_ssl=True, fingerprint=None,\ + use_dns_cache=False, \ + family=0, \ ssl_context=None, conn_timeout=None, \ keepalive_timeout=30, limit=None, share_cookies=False, \ force_close=False, loop=None) @@ -660,8 +661,16 @@ TCPConnector .. deprecated:: 0.17 - :param int family: TCP socket family, ``AF_INET`` by default - (*IPv4*). For *IPv6* use ``AF_INET6``. + :param int family: TCP socket family, both IPv4 and IPv6 by default. + For *IPv4* only use :const:`socket.AF_INET`, + for *IPv6* only -- :const:`socket.AF_INET6`. + + .. versionchanged:: 0.18 + + *family* is `0` by default, that means both IPv4 and IPv6 are + accepted. To specify only concrete version please pass + :const:`socket.AF_INET` or :const:`socket.AF_INET6` + explicitly. :param ssl.SSLContext ssl_context: ssl context used for processing *HTTPS* requests (optional). diff --git a/tests/test_connector.py b/tests/test_connector.py index a340b2a0fda..c5e4d5605ba 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -467,7 +467,7 @@ def test_tcp_connector_ctor(self): self.assertFalse(conn.resolve) self.assertFalse(conn.use_dns_cache) - self.assertEqual(conn.family, socket.AF_INET) + self.assertEqual(conn.family, 0) with self.assertWarns(DeprecationWarning): self.assertEqual(conn.resolved_hosts, {})