[Python-checkins] cpython (merge 3.2 -> default): Merge universal newlines-related fixes (issue #13119)
antoine.pitrou
python-checkins at python.org
Sun Aug 5 00:29:47 CEST 2012
http://hg.python.org/cpython/rev/e4a87f0253e9
changeset: 78422:e4a87f0253e9
parent: 78419:9ba8d0b3ff18
parent: 78421:481f5d9ef577
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sun Aug 05 00:25:31 2012 +0200
summary:
Merge universal newlines-related fixes (issue #13119)
files:
Lib/test/test_subprocess.py | 54 ++++++++++++------------
Lib/test/test_sys.py | 3 +-
2 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -563,21 +563,22 @@
def test_universal_newlines(self):
p = subprocess.Popen([sys.executable, "-c",
'import sys,os;' + SETBINARY +
- 'sys.stdout.write(sys.stdin.readline());'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line2\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write(sys.stdin.read());'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line4\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line5\\r\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line6\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline7");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline8");'],
+ 'buf = sys.stdout.buffer;'
+ 'buf.write(sys.stdin.readline().encode());'
+ 'buf.flush();'
+ 'buf.write(b"line2\\n");'
+ 'buf.flush();'
+ 'buf.write(sys.stdin.read().encode());'
+ 'buf.flush();'
+ 'buf.write(b"line4\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line5\\r\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line6\\r");'
+ 'buf.flush();'
+ 'buf.write(b"\\nline7");'
+ 'buf.flush();'
+ 'buf.write(b"\\nline8");'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
universal_newlines=1)
@@ -597,17 +598,18 @@
# universal newlines through communicate()
p = subprocess.Popen([sys.executable, "-c",
'import sys,os;' + SETBINARY +
- 'sys.stdout.write("line2\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line4\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line5\\r\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line6\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline7");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline8");'],
+ 'buf = sys.stdout.buffer;'
+ 'buf.write(b"line2\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line4\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line5\\r\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line6\\r");'
+ 'buf.flush();'
+ 'buf.write(b"\\nline7");'
+ 'buf.flush();'
+ 'buf.write(b"\\nline8");'],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
universal_newlines=1)
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -535,7 +535,8 @@
p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
stdout = subprocess.PIPE, env=env)
out = p.communicate()[0].strip()
- self.assertEqual(out, "\xa2\n".encode("cp424"))
+ expected = ("\xa2" + os.linesep).encode("cp424")
+ self.assertEqual(out, expected)
env["PYTHONIOENCODING"] = "ascii:replace"
p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list