Fixed the semantic of timeout for socket.create_connection and
all the upper level libraries that use it, including urllib2.
Added and fixed some tests, and changed docs correspondingly.
Thanks to John J Lee for the patch and the pusing, :)
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index e5a8167..16feee5 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -207,12 +207,11 @@
.. function:: create_connection(address[, timeout])
- Connects to the *address* received (as usual, a ``(host, port)`` pair), with an
- optional timeout for the connection. Especially useful for higher-level
- protocols, it is not normally used directly from application-level code.
- Passing the optional *timeout* parameter will set the timeout on the socket
- instance (if it is not given or ``None``, the global default timeout setting is
- used).
+ Convenience function. Connect to *address* (a 2-tuple ``(host, port)``),
+ and return the socket object. Passing the optional *timeout* parameter will
+ set the timeout on the socket instance before attempting to connect. If no
+ *timeout* is supplied, the global default timeout setting returned by
+ :func:`getdefaulttimeout` is used.
.. versionadded:: 2.6