~pythonregexp2.7/python/issue2636-12

« back to all changes in this revision

Viewing changes to Lib/telnetlib.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:52:42 UTC
  • mfrom: (39033.1.3 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609145242-9m268zc6u87rp1vp
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
 
185
185
    """
186
186
 
187
 
    def __init__(self, host=None, port=0, timeout=None):
 
187
    def __init__(self, host=None, port=0,
 
188
                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
188
189
        """Constructor.
189
190
 
190
191
        When called without arguments, create an unconnected instance.
191
 
        With a hostname argument, it connects the instance; a port
192
 
        number is optional.
193
 
 
 
192
        With a hostname argument, it connects the instance; port number
 
193
        and timeout are optional.
194
194
        """
195
195
        self.debuglevel = DEBUGLEVEL
196
196
        self.host = host
208
208
        if host is not None:
209
209
            self.open(host, port, timeout)
210
210
 
211
 
    def open(self, host, port=0, timeout=None):
 
211
    def open(self, host, port=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
212
212
        """Connect to a host.
213
213
 
214
214
        The optional second argument is the port number, which
215
215
        defaults to the standard telnet port (23).
216
216
 
217
217
        Don't try to reopen an already connected instance.
218
 
 
219
218
        """
220
219
        self.eof = 0
221
220
        if not port:
222
221
            port = TELNET_PORT
223
222
        self.host = host
224
223
        self.port = port
225
 
        if timeout is not None:
226
 
            self.timeout = timeout
227
 
        self.sock = socket.create_connection((host, port), self.timeout)
 
224
        self.timeout = timeout
 
225
        self.sock = socket.create_connection((host, port), timeout)
228
226
 
229
227
    def __del__(self):
230
228
        """Destructor -- close the connection."""