From: Guido van Rossum Date: Mon, 29 Oct 2007 16:42:51 +0000 (+0000) Subject: Issue 1340 by Amaury Forgeot d'Arc (with help from Christian Heimes, X-Git-Tag: v3.0a2~258 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d2125596844b507e213b7b671cfe8d18902d437;p=python Issue 1340 by Amaury Forgeot d'Arc (with help from Christian Heimes, and my own interpretation). Don't pass the newline= flag to StringIO in SpooledTemporaryFile. This avoids doubling newlines when the file is rolled over. --- diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 3b21ff2935..d725a9d0b6 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -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,