Kaydet (Commit) 69a06dd5 authored tarafından Petri Lehtinen's avatar Petri Lehtinen

#11062: Fix universal newline support in Babyl._install_message()

...@@ -1447,10 +1447,17 @@ class Babyl(_singlefileMailbox): ...@@ -1447,10 +1447,17 @@ class Babyl(_singlefileMailbox):
else: else:
break break
while True: while True:
buffer = message.read(4096) # Buffer size is arbitrary. line = message.readline()
if not buffer: if not line:
break break
self._file.write(buffer.replace(b'\n', linesep)) # Universal newline support.
if line.endswith(b'\r\n'):
line = line[:-2] + linesep
elif line.endswith(b'\r'):
line = line[:-1] + linesep
elif line.endswith(b'\n'):
line = line[:-1] + linesep
self._file.write(line)
else: else:
raise TypeError('Invalid message type: %s' % type(message)) raise TypeError('Invalid message type: %s' % type(message))
stop = self._file.tell() stop = self._file.tell()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment