~pythonregexp2.7/python/issue2636-01

« back to all changes in this revision

Viewing changes to Lib/ftplib.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:37:21 UTC
  • mfrom: (39022.1.14 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609143721-bj0g1mwta28038da
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    from socket import getfqdn; socket.getfqdn = getfqdn; del getfqdn
45
45
except ImportError:
46
46
    import socket
 
47
from socket import _GLOBAL_DEFAULT_TIMEOUT
47
48
 
48
49
__all__ = ["FTP","Netrc"]
49
50
 
71
72
# Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
72
73
CRLF = '\r\n'
73
74
 
74
 
 
75
75
# The class itself
76
76
class FTP:
77
77
 
109
109
    # Initialize host to localhost, port to standard ftp port
110
110
    # Optional arguments are host (for connect()),
111
111
    # and user, passwd, acct (for login())
112
 
    def __init__(self, host='', user='', passwd='', acct='', timeout=None):
 
112
    def __init__(self, host='', user='', passwd='', acct='',
 
113
                 timeout=_GLOBAL_DEFAULT_TIMEOUT):
113
114
        self.timeout = timeout
114
115
        if host:
115
116
            self.connect(host)
116
117
            if user:
117
118
                self.login(user, passwd, acct)
118
119
 
119
 
    def connect(self, host='', port=0, timeout=None):
 
120
    def connect(self, host='', port=0, timeout=-999):
120
121
        '''Connect to host.  Arguments are:
121
122
         - host: hostname to connect to (string, default previous host)
122
123
         - port: port to connect to (integer, default previous port)
125
126
            self.host = host
126
127
        if port > 0:
127
128
            self.port = port
128
 
        if timeout is not None:
 
129
        if timeout != -999:
129
130
            self.timeout = timeout
130
131
        self.sock = socket.create_connection((self.host, self.port), self.timeout)
131
132
        self.af = self.sock.family