summaryrefslogtreecommitdiffstats
path: root/Lib/mailbox.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-07-20 15:24:01 (GMT)
committerGuido van Rossum <guido@python.org>1998-07-20 15:24:01 (GMT)
commit7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34 (patch)
tree957b9a88784cccec31a779567021a7bcf9d83046 /Lib/mailbox.py
parenta9f445cd8d7360e7cc9a0026bd31d3d37e8450f3 (diff)
downloadcpython-7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34.zip
cpython-7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34.tar.gz
cpython-7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34.tar.bz2
Patch by Piet van Oostrum to avoid calculating with the result of
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.)
Diffstat (limited to 'Lib/mailbox.py')
-rwxr-xr-xLib/mailbox.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index 9cf3e07..a8f705c 100755
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -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):