mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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.)
This commit is contained in:
parent
a9f445cd8d
commit
7333c4cafc
1 changed files with 5 additions and 6 deletions
|
@ -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):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue