[Python-checkins] cpython (merge 3.4 -> default): Open files in binary mode to avoid newlines transformation.

serhiy.storchaka python-checkins at python.org
Sat Apr 4 09:37:48 CEST 2015


https://hg.python.org/cpython/rev/9db237815042
changeset: 95435:9db237815042
parent: 95432:fca669149d8a
parent: 95434:f3fe5e9ee7e4
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Apr 04 10:36:50 2015 +0300
summary:
 Open files in binary mode to avoid newlines transformation.
files:
 Lib/test/test_doctest.py | 8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -2644,8 +2644,8 @@
 
 >>> import tempfile, os
 >>> fn = tempfile.mktemp()
- >>> with open(fn, 'w') as f:
- ... f.write('Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n')
+ >>> with open(fn, 'wb') as f:
+ ... f.write(b'Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n')
 35
 >>> doctest.testfile(fn, False)
 TestResults(failed=0, attempted=1)
@@ -2654,8 +2654,8 @@
 And now *nix line endings:
 
 >>> fn = tempfile.mktemp()
- >>> with open(fn, 'w') as f:
- ... f.write('Test:\n\n >>> x = 1 + 1\n\nDone.\n')
+ >>> with open(fn, 'wb') as f:
+ ... f.write(b'Test:\n\n >>> x = 1 + 1\n\nDone.\n')
 30
 >>> doctest.testfile(fn, False)
 TestResults(failed=0, attempted=1)
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /