Skip to content

Commit

Permalink
imaplib: read/readline: save multipart buffer tail
Browse files Browse the repository at this point in the history
For resilience if read() or readline() ever complete with more than one
bytes object remaining in the buffer. This is not expected to happen,
but it seems wise to be prepared for a future change making it possible.
  • Loading branch information
foresto committed Jan 10, 2025
1 parent a47bcb4 commit 7fc4b78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/imaplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def read(self, size):

if len(buf) >= size:
parts.append(buf[:size])
self._readbuf = [buf[size:]]
self._readbuf = [buf[size:]] + self._readbuf[len(parts):]
break
parts.append(buf)
size -= len(buf)
Expand Down Expand Up @@ -389,7 +389,7 @@ def readline(self):
if pos != -1:
pos += 1
parts.append(buf[:pos])
self._readbuf = [buf[pos:]]
self._readbuf = [buf[pos:]] + self._readbuf[len(parts):]
break
parts.append(buf)
length += len(buf)
Expand Down

0 comments on commit 7fc4b78

Please sign in to comment.