[New-bugs-announce] [issue1340] correction for test_tempfile in py3k on Windows

Amaury Forgeot d'Arc report at bugs.python.org
Sat Oct 27 01:28:09 CEST 2007

New submission from Amaury Forgeot d'Arc:

This tiny patch correct a failure in test_tempfile on Windows: in
SpooledTemporaryFile, avoid translating the newlines twice.
Otherwise, in "universal" text mode, \n gets transformed to \r\n, then
to \r\r\n, which is read as \n\n.
Passing the encoding is OK, since the round-trip gives the same result,
and it allow encoding errors to occur at the right place.

Index: Lib/tempfile.py
--- Lib/tempfile.py     (revision 58680)
+++ Lib/tempfile.py     (working copy)
@@ -495,7 +495,7 @@
         if 'b' in mode:
             self._file = _io.BytesIO()
-            self._file = _io.StringIO(encoding=encoding, newline=newline)
+            self._file = _io.StringIO(encoding=encoding)
         self._max_size = max_size
         self._rolled = False
         self._TemporaryFileArgs = {'mode': mode, 'buffering': buffering,

components: Windows
messages: 56830
nosy: amaury.forgeotdarc
severity: normal
status: open
title: correction for test_tempfile in py3k on Windows
versions: Python 3.0

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list