summaryrefslogtreecommitdiff
path: root/Lib/ftplib.py
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-05-29 16:39:26 +0000
committerFacundo Batista <facundobatista@gmail.com>2008-05-29 16:39:26 +0000
commitba96b052e2159d8834beeb900956ee659b1c1761 (patch)
treeb664c5276d2f61c95255b1240d96df2aa8523f04 /Lib/ftplib.py
parent75fbf722c6ec0096303fe0b89a9c4f583477efeb (diff)
downloadcpython-ba96b052e2159d8834beeb900956ee659b1c1761.tar.gz
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, :)
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r--Lib/ftplib.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index a915b2d31e..820c345ee7 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -44,6 +44,7 @@ try:
from socket import getfqdn; socket.getfqdn = getfqdn; del getfqdn
except ImportError:
import socket
+from socket import _GLOBAL_DEFAULT_TIMEOUT
__all__ = ["FTP","Netrc"]
@@ -71,7 +72,6 @@ all_errors = (Error, IOError, EOFError)
# Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
CRLF = '\r\n'
-
# The class itself
class FTP:
@@ -109,14 +109,15 @@ class FTP:
# Initialize host to localhost, port to standard ftp port
# Optional arguments are host (for connect()),
# and user, passwd, acct (for login())
- def __init__(self, host='', user='', passwd='', acct='', timeout=None):
+ def __init__(self, host='', user='', passwd='', acct='',
+ timeout=_GLOBAL_DEFAULT_TIMEOUT):
self.timeout = timeout
if host:
self.connect(host)
if user:
self.login(user, passwd, acct)
- def connect(self, host='', port=0, timeout=None):
+ def connect(self, host='', port=0, timeout=-999):
'''Connect to host. Arguments are:
- host: hostname to connect to (string, default previous host)
- port: port to connect to (integer, default previous port)
@@ -125,7 +126,7 @@ class FTP:
self.host = host
if port > 0:
self.port = port
- if timeout is not None:
+ if timeout != -999:
self.timeout = timeout
self.sock = socket.create_connection((self.host, self.port), self.timeout)
self.af = self.sock.family