diff options
author | Guido van Rossum <guido@python.org> | 2007-05-24 04:05:35 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-24 04:05:35 (GMT) |
commit | fa0054aa732176a1f9b1c79cd20198f43cfed334 (patch) | |
tree | 3a354b90b0d2876ab8c0fd72866a14ce2b879251 /Lib/io.py | |
parent | c126e8aae30043792f6318a5c4318b8203e75b33 (diff) | |
download | cpython-fa0054aa732176a1f9b1c79cd20198f43cfed334.zip cpython-fa0054aa732176a1f9b1c79cd20198f43cfed334.tar.gz cpython-fa0054aa732176a1f9b1c79cd20198f43cfed334.tar.bz2 |
Make test_subprocess work. Fix universal newlines in io.py.
Diffstat (limited to 'Lib/io.py')
-rw-r--r-- | Lib/io.py | 20 |
1 files changed, 6 insertions, 14 deletions
@@ -1114,14 +1114,6 @@ class TextIOWrapper(TextIOBase): self._decoder = decoder return orig_pos - def _simplify(self, u): - # XXX Hack until str/unicode unification: return str instead - # of unicode if it's all ASCII - try: - return str(u) - except UnicodeEncodeError: - return u - def read(self, n=None): if n is None: n = -1 @@ -1131,7 +1123,7 @@ class TextIOWrapper(TextIOBase): res += decoder.decode(self.buffer.read(), True) self._pending = "" self._snapshot = None - return self._simplify(res) + return res.replace("\r\n", "\n") else: while len(res) < n: readahead, pending = self._read_chunk() @@ -1139,7 +1131,7 @@ class TextIOWrapper(TextIOBase): if not readahead: break self._pending = res[n:] - return self._simplify(res[:n]) + return res[:n].replace("\r\n", "\n") def __next__(self): self._telling = False @@ -1155,9 +1147,9 @@ class TextIOWrapper(TextIOBase): # XXX Hack to support limit argument, for backwards compatibility line = self.readline() if len(line) <= limit: - return self._simplify(line) + return line line, self._pending = line[:limit], line[limit:] + self._pending - return self._simplify(line) + return line line = self._pending start = 0 @@ -1210,9 +1202,9 @@ class TextIOWrapper(TextIOBase): # XXX Update self.newlines here if we want to support that if self._fix_newlines and ending not in ("\n", ""): - return self._simplify(line[:endpos] + "\n") + return line[:endpos] + "\n" else: - return self._simplify(line[:nextpos]) + return line[:nextpos] class StringIO(TextIOWrapper): |