diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-09-28 14:37:55 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-09-28 14:37:55 (GMT) |
commit | d8b509b192a67f0f217ae52ed81fc91bc27a1818 (patch) | |
tree | adab8922723e179e67d546100d19d06d444d7599 /Lib/codecs.py | |
parent | a6e50f589fa328a77b70cde0747f70210c650f49 (diff) | |
download | cpython-d8b509b192a67f0f217ae52ed81fc91bc27a1818.zip cpython-d8b509b192a67f0f217ae52ed81fc91bc27a1818.tar.gz cpython-d8b509b192a67f0f217ae52ed81fc91bc27a1818.tar.bz2 |
#13012: use splitlines(keepends=True/False) instead of splitlines(0/1).
Diffstat (limited to 'Lib/codecs.py')
-rw-r--r-- | Lib/codecs.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/codecs.py b/Lib/codecs.py index b150d64..e63a0c6 100644 --- a/Lib/codecs.py +++ b/Lib/codecs.py @@ -484,7 +484,7 @@ class StreamReader(Codec): if firstline: newchars, decodedbytes = \ self.decode(data[:exc.start], self.errors) - lines = newchars.splitlines(True) + lines = newchars.splitlines(keepends=True) if len(lines)<=1: raise else: @@ -526,7 +526,7 @@ class StreamReader(Codec): self.charbuffer = self.linebuffer[0] self.linebuffer = None if not keepends: - line = line.splitlines(False)[0] + line = line.splitlines(keepends=False)[0] return line readsize = size or 72 @@ -543,7 +543,7 @@ class StreamReader(Codec): data += self.read(size=1, chars=1) line += data - lines = line.splitlines(True) + lines = line.splitlines(keepends=True) if lines: if len(lines) > 1: # More than one line result; the first line is a full line @@ -559,10 +559,10 @@ class StreamReader(Codec): # only one remaining line, put it back into charbuffer self.charbuffer = lines[0] + self.charbuffer if not keepends: - line = line.splitlines(False)[0] + line = line.splitlines(keepends=False)[0] break line0withend = lines[0] - line0withoutend = lines[0].splitlines(False)[0] + line0withoutend = lines[0].splitlines(keepends=False)[0] if line0withend != line0withoutend: # We really have a line end # Put the rest back together and keep it until the next call self.charbuffer = self._empty_charbuffer.join(lines[1:]) + \ @@ -575,7 +575,7 @@ class StreamReader(Codec): # we didn't get anything or this was our only try if not data or size is not None: if line and not keepends: - line = line.splitlines(False)[0] + line = line.splitlines(keepends=False)[0] break if readsize < 8000: readsize *= 2 @@ -803,7 +803,7 @@ class StreamRecoder: data = self.reader.read() data, bytesencoded = self.encode(data, self.errors) - return data.splitlines(1) + return data.splitlines(keepends=True) def __next__(self): |