Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 573b1fd commit 8861494Copy full SHA for 8861494
1 file changed
Lib/mailbox.py
@@ -1450,10 +1450,17 @@ def _install_message(self, message):
1450
else:
1451
break
1452
while True:
1453
- buffer = message.read(4096) # Buffer size is arbitrary.
1454
- if not buffer:
+ line = message.readline()
+ if not line:
1455
1456
- self._file.write(buffer.replace(b'\n', linesep))
+ # Universal newline support.
1457
+ if line.endswith(b'\r\n'):
1458
+ line = line[:-2] + linesep
1459
+ elif line.endswith(b'\r'):
1460
+ line = line[:-1] + linesep
1461
+ elif line.endswith(b'\n'):
1462
1463
+ self._file.write(line)
1464
1465
raise TypeError('Invalid message type: %s' % type(message))
1466
stop = self._file.tell()
0 commit comments