diff options
author | Facundo Batista <facundobatista@gmail.com> | 2008-05-29 16:39:26 (GMT) |
---|---|---|
committer | Facundo Batista <facundobatista@gmail.com> | 2008-05-29 16:39:26 (GMT) |
commit | 4f1b1ed975fe25170d00559e63f992c9bf8e9b8a (patch) | |
tree | 0f2a0434dc9ad0181633f649611e417aa4a6ea61 /Lib/telnetlib.py | |
parent | f18a70720542268586e271bbadab3fb0332b8a39 (diff) | |
download | cpython-4f1b1ed975fe25170d00559e63f992c9bf8e9b8a.zip cpython-4f1b1ed975fe25170d00559e63f992c9bf8e9b8a.tar.gz cpython-4f1b1ed975fe25170d00559e63f992c9bf8e9b8a.tar.bz2 |
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/telnetlib.py')
-rw-r--r-- | Lib/telnetlib.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py index f4c01e4..2bfd9cd 100644 --- a/Lib/telnetlib.py +++ b/Lib/telnetlib.py @@ -184,13 +184,13 @@ class Telnet: """ - def __init__(self, host=None, port=0, timeout=None): + def __init__(self, host=None, port=0, + timeout=socket._GLOBAL_DEFAULT_TIMEOUT): """Constructor. When called without arguments, create an unconnected instance. - With a hostname argument, it connects the instance; a port - number is optional. - + With a hostname argument, it connects the instance; port number + and timeout are optional. """ self.debuglevel = DEBUGLEVEL self.host = host @@ -208,23 +208,21 @@ class Telnet: if host is not None: self.open(host, port, timeout) - def open(self, host, port=0, timeout=None): + def open(self, host, port=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): """Connect to a host. The optional second argument is the port number, which defaults to the standard telnet port (23). Don't try to reopen an already connected instance. - """ self.eof = 0 if not port: port = TELNET_PORT self.host = host self.port = port - if timeout is not None: - self.timeout = timeout - self.sock = socket.create_connection((host, port), self.timeout) + self.timeout = timeout + self.sock = socket.create_connection((host, port), timeout) def __del__(self): """Destructor -- close the connection.""" |