summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-29 16:42:51 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-29 16:42:51 (GMT)
commit5d2125596844b507e213b7b671cfe8d18902d437 (patch)
treeb9c0724442feaf83ebd653ebaac5f61a95a950bc /Lib/tempfile.py
parent1b16ca4ef1b903d09bf60d7f8616f6820fb397e1 (diff)
downloadcpython-5d2125596844b507e213b7b671cfe8d18902d437.zip
cpython-5d2125596844b507e213b7b671cfe8d18902d437.tar.gz
cpython-5d2125596844b507e213b7b671cfe8d18902d437.tar.bz2
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.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 3b21ff2..d725a9d 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,