Adds an optional source_address parameter to socket.create_connection().
For use by issue3972.
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index d778369..2e0c6d6 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -205,7 +205,7 @@
.. versionadded:: 2.3
-.. function:: create_connection(address[, timeout])
+.. function:: create_connection(address[, timeout[, source_address]])
Convenience function. Connect to *address* (a 2-tuple ``(host, port)``),
and return the socket object. Passing the optional *timeout* parameter will
@@ -215,6 +215,12 @@
.. versionadded:: 2.6
+ If supplied, *source_address* must be a 2-tuple ``(host, port)`` for the
+ socket to bind to as its source address before connecting. If host or port
+ are '' or 0 respectively the OS default behavior will be used.
+
+ .. versionadded:: 2.7
+
.. function:: getaddrinfo(host, port[, family[, socktype[, proto[, flags]]]])