mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
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, :)
This commit is contained in:
parent
f18a707205
commit
4f1b1ed975
24 changed files with 231 additions and 180 deletions
|
@ -2,6 +2,7 @@ import unittest
|
|||
from test import test_support
|
||||
|
||||
import os
|
||||
import socket
|
||||
import StringIO
|
||||
|
||||
import urllib2
|
||||
|
@ -551,14 +552,15 @@ class HandlerTests(unittest.TestCase):
|
|||
|
||||
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 @@ class HandlerTests(unittest.TestCase):
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue