]> granicus.if.org Git - python/commitdiff
Patch by Piet van Oostrum to avoid calculating with the result of
authorGuido van Rossum <guido@python.org>
Mon, 20 Jul 1998 15:24:01 +0000 (15:24 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 20 Jul 1998 15:24:01 +0000 (15:24 +0000)
fp.tell() -- that won't work on Windows.

(A patch for rfc822 is still needed for one case where it finds a bad
header line and wants to back up.)

Lib/mailbox.py

index 9cf3e076211654b4950108a5880bbd444c242812..a8f705c1d27880de1ecb51087f246d93f7c58fb7 100755 (executable)
@@ -52,8 +52,9 @@ class _Subfile:
                elif length > remaining:
                        length = remaining
                self.fp.seek(self.pos)
-               self.pos = self.pos + length
-               return self.fp.read(length)
+               data = self.fp.read(length)
+               self.pos = self.fp.tell()
+               return data
 
        def readline(self, length = None):
                if self.pos >= self.stop:
@@ -62,9 +63,7 @@ class _Subfile:
                        length = self.stop - self.pos
                self.fp.seek(self.pos)
                data = self.fp.readline(length)
-               if len(data) < length:
-                       length = len(data)
-               self.pos = self.pos + length
+               self.pos = self.fp.tell()
                return data
 
        def tell(self):
@@ -79,7 +78,7 @@ class _Subfile:
                        self.pos = self.stop + pos
 
        def close(self):
-               pass
+               del self.fp
 
 class UnixMailbox(_Mailbox):