#11062: Fix adding a message from file to Babyl mailbox
authorPetri Lehtinen <petri@digip.org>
Wed, 15 Aug 2012 11:00:40 +0000 (14:00 +0300)
committerPetri Lehtinen <petri@digip.org>
Wed, 15 Aug 2012 11:26:27 +0000 (14:26 +0300)
Lib/mailbox.py
Lib/test/test_mailbox.py
Misc/NEWS

index 8b00460ec6db8b0945606e36b18a85913f93c653..73fe7d648330e025df80c822d2369417379ac6dd 100644 (file)
@@ -1443,9 +1443,9 @@ class Babyl(_singlefileMailbox):
                     line = line[:-1] + b'\n'
                 self._file.write(line.replace(b'\n', linesep))
                 if line == b'\n' or not line:
-                    self._file.write(b'*** EOOH ***' + linesep)
                     if first_pass:
                         first_pass = False
+                        self._file.write(b'*** EOOH ***' + linesep)
                         message.seek(original_pos)
                     else:
                         break
index 9f1fdad383c90148c6294efe9d7b42743e25aefd..65120f7af9b49378e26225547bf7b23e50b5ce43 100644 (file)
@@ -148,20 +148,16 @@ class TestMailbox(TestBase):
             f.write(_bytes_sample_message)
             f.seek(0)
             key = self._box.add(f)
-        # See issue 11062
-        if not isinstance(self._box, mailbox.Babyl):
-            self.assertEqual(self._box.get_bytes(key).split(b'\n'),
-                _bytes_sample_message.split(b'\n'))
+        self.assertEqual(self._box.get_bytes(key).split(b'\n'),
+            _bytes_sample_message.split(b'\n'))
 
     def test_add_binary_nonascii_file(self):
         with tempfile.TemporaryFile('wb+') as f:
             f.write(self._non_latin_bin_msg)
             f.seek(0)
             key = self._box.add(f)
-        # See issue 11062
-        if not isinstance(self._box, mailbox.Babyl):
-            self.assertEqual(self._box.get_bytes(key).split(b'\n'),
-                self._non_latin_bin_msg.split(b'\n'))
+        self.assertEqual(self._box.get_bytes(key).split(b'\n'),
+            self._non_latin_bin_msg.split(b'\n'))
 
     def test_add_text_file_warns(self):
         with tempfile.TemporaryFile('w+') as f:
@@ -169,10 +165,8 @@ class TestMailbox(TestBase):
             f.seek(0)
             with self.assertWarns(DeprecationWarning):
                 key = self._box.add(f)
-        # See issue 11062
-        if not isinstance(self._box, mailbox.Babyl):
-            self.assertEqual(self._box.get_bytes(key).split(b'\n'),
-                _bytes_sample_message.split(b'\n'))
+        self.assertEqual(self._box.get_bytes(key).split(b'\n'),
+            _bytes_sample_message.split(b'\n'))
 
     def test_add_StringIO_warns(self):
         with self.assertWarns(DeprecationWarning):
index 5d69e955f61a7c7d559ea74296d9a5a8f4d03069..1e1e0c550aca6b1fb20423219ceadec1f565dbcc 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -101,6 +101,8 @@ Core and Builtins
 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.