]> granicus.if.org Git - python/commitdiff
Moved things around a bit in interact(), so outout is processed before
authorGuido van Rossum <guido@python.org>
Mon, 29 Dec 1997 20:05:45 +0000 (20:05 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 29 Dec 1997 20:05:45 +0000 (20:05 +0000)
input.  When an EOF is read, break out of the loop instead of (by
default) writing an empty line (which doesn't do much good).  Don't
close self when falling through the loop.

Lib/telnetlib.py

index 1a1c75edfdeb249dcd6d9959e81e7027dc2eb8bd..4784a6988e8abb7cf0c389c9bf8fd34527258bed 100644 (file)
@@ -376,9 +376,6 @@ class Telnet:
        """Interaction function, emulates a very dumb telnet client."""
        while 1:
            rfd, wfd, xfd = select.select([self, sys.stdin], [], [])
-           if sys.stdin in rfd:
-               line = sys.stdin.readline()
-               self.write(line)
            if self in rfd:
                try:
                    text = self.read_eager()
@@ -388,7 +385,11 @@ class Telnet:
                if text:
                    sys.stdout.write(text)
                    sys.stdout.flush()
-       self.close()
+           if sys.stdin in rfd:
+               line = sys.stdin.readline()
+               if not line:
+                   break
+               self.write(line)
 
     def expect(self, list, timeout=None):
        """Read until one from a list of a regular expressions matches.