]> granicus.if.org Git - python/commitdiff
Issue 1340 by Amaury Forgeot d'Arc (with help from Christian Heimes,
authorGuido van Rossum <guido@python.org>
Mon, 29 Oct 2007 16:42:51 +0000 (16:42 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 29 Oct 2007 16:42:51 +0000 (16:42 +0000)
and my own interpretation).
Don't pass the newline= flag to StringIO in SpooledTemporaryFile.
This avoids doubling newlines when the file is rolled over.

Lib/tempfile.py

index 3b21ff29353a840badb288f07ca1afd5ad5f4a35..d725a9d0b64606544e90f58e5dbb75f8a5d29203 100644 (file)
@@ -495,7 +495,10 @@ class SpooledTemporaryFile:
         if 'b' in mode:
             self._file = _io.BytesIO()
         else:
-            self._file = _io.StringIO(encoding=encoding, newline=newline)
+            # Setting newline="\n" avoids newline translation;
+            # this is important because otherwise on Windows we'd
+            # hget double newline translation upon rollover().
+            self._file = _io.StringIO(encoding=encoding, newline="\n")
         self._max_size = max_size
         self._rolled = False
         self._TemporaryFileArgs = {'mode': mode, 'buffering': buffering,