[Python-3000-checkins] r58701 - python/branches/py3k/Lib/tempfile.py
guido.van.rossum
python-3000-checkins at python.org
Mon Oct 29 17:42:52 CET 2007
Author: guido.van.rossum
Date: Mon Oct 29 17:42:51 2007
New Revision: 58701
Modified:
python/branches/py3k/Lib/tempfile.py
Log:
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.
Modified: python/branches/py3k/Lib/tempfile.py
==============================================================================
--- python/branches/py3k/Lib/tempfile.py (original)
+++ python/branches/py3k/Lib/tempfile.py Mon Oct 29 17:42:51 2007
@@ -495,7 +495,10 @@
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,
More information about the Python-3000-checkins
mailing list