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/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 8d17e05..1e93fdb 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -2,6 +2,7 @@
from test import test_support
import os
+import socket
import StringIO
import urllib2
@@ -551,14 +552,15 @@
class NullFTPHandler(urllib2.FTPHandler):
def __init__(self, data): self.data = data
- def connect_ftp(self, user, passwd, host, port, dirs, timeout=None):
+ def connect_ftp(self, user, passwd, host, port, dirs,
+ timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
self.user, self.passwd = user, passwd
self.host, self.port = host, port
self.dirs = dirs
self.ftpwrapper = MockFTPWrapper(self.data)
return self.ftpwrapper
- import ftplib, socket
+ import ftplib
data = "rheum rhaponicum"
h = NullFTPHandler(data)
o = h.parent = MockOpener()
@@ -691,7 +693,7 @@
self.req_headers = []
self.data = None
self.raise_on_endheaders = False
- def __call__(self, host, timeout=None):
+ def __call__(self, host, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
self.host = host
self.timeout = timeout
return self