[Python-checkins] cpython (2.7): 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/20c348914b22
changeset:   95433:20c348914b22
branch:      2.7
parent:      95429:1f28c8cca671
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sat Apr 04 10:36:15 2015 +0300
summary:
  Open files in binary mode to avoid newlines transformation.

files:
  Lib/test/test_doctest.py |  4 ++--
  1 files changed, 2 insertions(+), 2 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
@@ -2580,7 +2580,7 @@
 
     >>> 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 @@
 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)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list