From: Serhiy Storchaka Date: Sat, 4 Apr 2015 07:36:15 +0000 (+0300) Subject: Open files in binary mode to avoid newlines transformation. X-Git-Tag: v2.7.10rc1~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=baa6efdceb61eda39cb1df7ce7bd761bc2747f08;p=thirdparty%2FPython%2Fcpython.git Open files in binary mode to avoid newlines transformation. --- diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index 61c7ba74988f..c1e4c139e706 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -2580,7 +2580,7 @@ Windows line endings first: >>> import tempfile, os >>> fn = tempfile.mktemp() - >>> with open(fn, 'w') as f: + >>> with open(fn, 'wb') as f: ... f.write('Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n') >>> doctest.testfile(fn, False) TestResults(failed=0, attempted=1) @@ -2589,7 +2589,7 @@ Windows line endings first: And now *nix line endings: >>> fn = tempfile.mktemp() - >>> with open(fn, 'w') as f: + >>> with open(fn, 'wb') as f: ... f.write('Test:\n\n >>> x = 1 + 1\n\nDone.\n') >>> doctest.testfile(fn, False) TestResults(failed=0, attempted=1)