diff -r 493886a640b6 Lib/argparse.py --- a/Lib/argparse.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/argparse.py Sat Sep 24 00:01:17 2011 +0300 @@ -641,7 +641,7 @@ """ def _fill_text(self, text, width, indent): - return ''.join([indent + line for line in text.splitlines(True)]) + return ''.join(indent + line for line in text.splitlines(keepends=True)) class RawTextHelpFormatter(RawDescriptionHelpFormatter): diff -r 493886a640b6 Lib/codecs.py --- a/Lib/codecs.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/codecs.py Sat Sep 24 00:01:17 2011 +0300 @@ -484,7 +484,7 @@ 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 @@ 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 @@ 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 @@ # 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 @@ # 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 @@ data = self.reader.read() data, bytesencoded = self.encode(data, self.errors) - return data.splitlines(1) + return data.splitlines(keepends=True) def __next__(self): diff -r 493886a640b6 Lib/difflib.py --- a/Lib/difflib.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/difflib.py Sat Sep 24 00:01:17 2011 +0300 @@ -800,7 +800,7 @@ ... 2. Explicit is better than implicit. ... 3. Simple is better than complex. ... 4. Complex is better than complicated. - ... '''.splitlines(1) + ... '''.splitlines(keepends=True) >>> len(text1) 4 >>> text1[0][-1] @@ -809,7 +809,7 @@ ... 3. Simple is better than complex. ... 4. Complicated is better than complex. ... 5. Flat is better than nested. - ... '''.splitlines(1) + ... '''.splitlines(keepends=True) Next we instantiate a Differ object: @@ -896,8 +896,8 @@ Example: - >>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1))), + >>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(True), + ... 'ore\ntree\nemu\n'.splitlines(True))), ... end="") - one ? ^ @@ -1269,8 +1269,8 @@ Example: - >>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(1), - ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current')), + >>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(True), + ... 'zero\none\ntree\nfour\n'.splitlines(True), 'Original', 'Current')), ... end="") *** Original --- Current @@ -1339,8 +1339,8 @@ Example: - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1)) + >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), + ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) >>> print(''.join(diff), end="") - one ? ^ @@ -2034,8 +2034,8 @@ Examples: - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1)) + >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), + ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) >>> diff = list(diff) >>> print(''.join(restore(diff, 1)), end="") one diff -r 493886a640b6 Lib/doctest.py --- a/Lib/doctest.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/doctest.py Sat Sep 24 00:01:17 2011 +0300 @@ -1332,7 +1332,7 @@ m = self.__LINECACHE_FILENAME_RE.match(filename) if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] - return example.source.splitlines(True) + return example.source.splitlines(keepends=True) else: return self.save_linecache_getlines(filename, module_globals) @@ -1595,8 +1595,8 @@ # Check if we should use diff. if self._do_a_fancy_diff(want, got, optionflags): # Split want & got into lines. - want_lines = want.splitlines(True) # True == keep line ends - got_lines = got.splitlines(True) + want_lines = want.splitlines(keepends=True) + got_lines = got.splitlines(keepends=True) # Use difflib to find their differences. if optionflags & REPORT_UDIFF: diff = difflib.unified_diff(want_lines, got_lines, n=2) diff -r 493886a640b6 Lib/lib2to3/refactor.py --- a/Lib/lib2to3/refactor.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/lib2to3/refactor.py Sat Sep 24 00:01:17 2011 +0300 @@ -560,7 +560,7 @@ block_lineno = None indent = None lineno = 0 - for line in input.splitlines(True): + for line in input.splitlines(keepends=True): lineno += 1 if line.lstrip().startswith(self.PS1): if block is not None: @@ -604,7 +604,7 @@ filename, lineno, err.__class__.__name__, err) return block if self.refactor_tree(tree, filename): - new = str(tree).splitlines(True) + new = str(tree).splitlines(keepends=True) # Undo the adjustment of the line numbers in wrap_toks() below. clipped, new = new[:lineno-1], new[lineno-1:] assert clipped == ["\n"] * (lineno-1), clipped diff -r 493886a640b6 Lib/string.py --- a/Lib/string.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/string.py Sat Sep 24 00:01:17 2011 +0300 @@ -84,7 +84,7 @@ def _invalid(self, mo): i = mo.start('invalid') - lines = self.template[:i].splitlines(True) + lines = self.template[:i].splitlines(keepends=True) if not lines: colno = 1 lineno = 1 diff -r 493886a640b6 Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/test/test_calendar.py Sat Sep 24 00:01:17 2011 +0300 @@ -177,7 +177,7 @@ return not c.isspace() and not c.isdigit() lines = [] - for line in s.splitlines(False): + for line in s.splitlines(keepends=False): # Drop texts, as they are locale dependent if line and not filter(neitherspacenordigit, line): lines.append(line) diff -r 493886a640b6 Lib/test/test_email/__init__.py --- a/Lib/test/test_email/__init__.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/test/test_email/__init__.py Sat Sep 24 00:01:17 2011 +0300 @@ -38,7 +38,7 @@ return email.message_from_file(fp) def _bytes_repr(self, b): - return [repr(x) for x in b.splitlines(True)] + return [repr(x) for x in b.splitlines(keepends=True)] def assertBytesEqual(self, first, second, msg): """Our byte strings are really encoded strings; improve diff output""" diff -r 493886a640b6 Lib/test/test_gzip.py --- a/Lib/test/test_gzip.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/test/test_gzip.py Sat Sep 24 00:01:17 2011 +0300 @@ -139,7 +139,7 @@ with io.BufferedReader(f) as r: lines = [line for line in r] - self.assertEqual(lines, 50 * data1.splitlines(True)) + self.assertEqual(lines, 50 * data1.splitlines(keepends=True)) def test_readline(self): self.test_write() @@ -340,7 +340,7 @@ def test_textio_readlines(self): # Issue #10791: TextIOWrapper.readlines() fails when wrapping GzipFile. - lines = (data1 * 50).decode("ascii").splitlines(True) + lines = (data1 * 50).decode("ascii").splitlines(keepends=True) self.test_write() with gzip.GzipFile(self.filename, 'r') as f: with io.TextIOWrapper(f, encoding="ascii") as t: diff -r 493886a640b6 Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/test/test_inspect.py Sat Sep 24 00:01:17 2011 +0300 @@ -304,7 +304,7 @@ getlines = linecache.getlines def monkey(filename, module_globals=None): if filename == fn: - return source.splitlines(True) + return source.splitlines(keepends=True) else: return getlines(filename, module_globals) linecache.getlines = monkey diff -r 493886a640b6 Lib/test/test_io.py --- a/Lib/test/test_io.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/test/test_io.py Sat Sep 24 00:01:17 2011 +0300 @@ -1935,8 +1935,8 @@ testdata = b"AAA\nBB\x00B\nCCC\rDDD\rEEE\r\nFFF\r\nGGG" normalized = testdata.replace(b"\r\n", b"\n").replace(b"\r", b"\n") for newline, expected in [ - (None, normalized.decode("ascii").splitlines(True)), - ("", testdata.decode("ascii").splitlines(True)), + (None, normalized.decode("ascii").splitlines(keepends=True)), + ("", testdata.decode("ascii").splitlines(keepends=True)), ("\n", ["AAA\n", "BB\x00B\n", "CCC\rDDD\rEEE\r\n", "FFF\r\n", "GGG"]), ("\r\n", ["AAA\nBB\x00B\nCCC\rDDD\rEEE\r\n", "FFF\r\n", "GGG"]), ("\r", ["AAA\nBB\x00B\nCCC\r", "DDD\r", "EEE\r", "\nFFF\r", "\nGGG"]), diff -r 493886a640b6 Lib/test/test_nntplib.py --- a/Lib/test/test_nntplib.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/test/test_nntplib.py Sat Sep 24 00:01:17 2011 +0300 @@ -1033,12 +1033,12 @@ self.assertEqual(resp, success_resp) # With an iterable of terminated lines def iterlines(b): - return iter(b.splitlines(True)) + return iter(b.splitlines(keepends=True)) resp = self._check_post_ihave_sub(func, *args, file_factory=iterlines) self.assertEqual(resp, success_resp) # With an iterable of non-terminated lines def iterlines(b): - return iter(b.splitlines(False)) + return iter(b.splitlines(keepends=False)) resp = self._check_post_ihave_sub(func, *args, file_factory=iterlines) self.assertEqual(resp, success_resp) diff -r 493886a640b6 Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/test/test_pydoc.py Sat Sep 24 00:01:17 2011 +0300 @@ -238,8 +238,8 @@ def print_diffs(text1, text2): "Prints unified diffs for two texts" # XXX now obsolete, use unittest built-in support - lines1 = text1.splitlines(True) - lines2 = text2.splitlines(True) + lines1 = text1.splitlines(keepends=True) + lines2 = text2.splitlines(keepends=True) diffs = difflib.unified_diff(lines1, lines2, n=0, fromfile='expected', tofile='got') print('\n' + ''.join(diffs)) diff -r 493886a640b6 Lib/test/test_tokenize.py --- a/Lib/test/test_tokenize.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/test/test_tokenize.py Sat Sep 24 00:01:17 2011 +0300 @@ -600,7 +600,7 @@ f.close() tokens1 = [tok[:2] for tok in token_list] new_bytes = untokenize(tokens1) - readline = (line for line in new_bytes.splitlines(1)).__next__ + readline = (line for line in new_bytes.splitlines(keepends=True)).__next__ tokens2 = [tok[:2] for tok in tokenize(readline)] return tokens1 == tokens2 diff -r 493886a640b6 Lib/unittest/case.py --- a/Lib/unittest/case.py Fri Sep 23 13:53:06 2011 -0400 +++ b/Lib/unittest/case.py Sat Sep 24 00:01:17 2011 +0300 @@ -1010,8 +1010,8 @@ if (len(first) > self._diffThreshold or len(second) > self._diffThreshold): self._baseAssertEqual(first, second, msg) - firstlines = first.splitlines(True) - secondlines = second.splitlines(True) + firstlines = first.splitlines(keepends=True) + secondlines = second.splitlines(keepends=True) if len(firstlines) == 1 and first.strip('\r\n') == first: firstlines = [first + '\n'] secondlines = [second + '\n']