summaryrefslogtreecommitdiffstats
path: root/Lib/telnetlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/telnetlib.py')
-rw-r--r--Lib/telnetlib.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index 33029e1..56c5d70 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."""