[Python-checkins] cpython (3.4): 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/f3fe5e9ee7e4
changeset: 95434:f3fe5e9ee7e4
branch: 3.4
parent: 95430:36eca0b259e2
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Apr 04 10:36:25 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
@@ -2624,8 +2624,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)
@@ -2634,8 +2634,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