[Python-checkins] cpython (2.7): #11062: Fix adding a message from file to Babyl mailbox

petri.lehtinen python-checkins at python.org
Wed Aug 15 13:42:20 CEST 2012


http://hg.python.org/cpython/rev/ad8c9725c041
changeset: 78584:ad8c9725c041
branch: 2.7
parent: 78582:e64d4518b23c
user: Petri Lehtinen <petri at digip.org>
date: Wed Aug 15 14:22:46 2012 +0300
summary:
 #11062: Fix adding a message from file to Babyl mailbox
files:
 Lib/mailbox.py | 2 +-
 Lib/test/test_mailbox.py | 13 +++++++++++++
 Misc/NEWS | 2 ++
 3 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -1386,9 +1386,9 @@
 line = message.readline()
 self._file.write(line.replace('\n', os.linesep))
 if line == '\n' or line == '':
- self._file.write('*** EOOH ***' + os.linesep)
 if first_pass:
 first_pass = False
+ self._file.write('*** EOOH ***' + os.linesep)
 message.seek(original_pos)
 else:
 break
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -8,6 +8,7 @@
 import re
 import shutil
 import StringIO
+import tempfile
 from test import test_support
 import unittest
 import mailbox
@@ -75,6 +76,18 @@
 for i in (1, 2, 3, 4):
 self._check_sample(self._box[keys[i]])
 
+ def test_add_file(self):
+ with tempfile.TemporaryFile('w+') as f:
+ f.write(_sample_message)
+ f.seek(0)
+ key = self._box.add(f)
+ self.assertEqual(self._box.get_string(key).split('\n'),
+ _sample_message.split('\n'))
+
+ def test_add_StringIO(self):
+ key = self._box.add(StringIO.StringIO(self._template % "0"))
+ self.assertEqual(self._box.get_string(key), self._template % "0")
+
 def test_remove(self):
 # Remove messages using remove()
 self._test_remove_or_delitem(self._box.remove)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -92,6 +92,8 @@
 Library
 -------
 
+- Issue #11062: Fix adding a message from file to Babyl mailbox.
+
 - Issue #15646: Prevent equivalent of a fork bomb when using
 multiprocessing on Windows without the "if __name__ == '__main__'"
 idiom.
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /