]> granicus.if.org Git - python/commitdiff
#15036: Make a repeated changes and flushes work with single-file mailboxes
authorPetri Lehtinen <petri@digip.org>
Fri, 15 Jun 2012 17:50:51 +0000 (20:50 +0300)
committerPetri Lehtinen <petri@digip.org>
Fri, 15 Jun 2012 17:59:31 +0000 (20:59 +0300)
Lib/mailbox.py
Lib/test/test_mailbox.py
Misc/NEWS

index a6777293861bc0828d09a1d7ad92df1f99305be0..2be4c8384d652fa7b63e815f1c1cd233fadd686c 100644 (file)
@@ -675,6 +675,7 @@ class _singlefileMailbox(Mailbox):
                     new_file.write(buffer)
                 new_toc[key] = (new_start, new_file.tell())
                 self._post_message_hook(new_file)
+            self._file_length = new_file.tell()
         except:
             new_file.close()
             os.remove(new_file.name)
index f885d33eeada5446f94b54e9400750eabc968e02..91c8983f213f16ccedd16e878cbea1a07ba506c3 100644 (file)
@@ -500,6 +500,17 @@ class TestMailbox(TestBase):
         # Write changes to disk
         self._test_flush_or_close(self._box.flush, True)
 
+    def test_popitem_and_flush_twice(self):
+        # See #15036.
+        self._box.add(self._template % 0)
+        self._box.add(self._template % 1)
+        self._box.flush()
+
+        self._box.popitem()
+        self._box.flush()
+        self._box.popitem()
+        self._box.flush()
+
     def test_lock_unlock(self):
         # Lock and unlock the mailbox
         self.assertFalse(os.path.exists(self._get_lock_path()))
index 22cf31cb693a87aad5e33bc1d7b3b0b3c053cfa8..f9abb667202b90e78d4f27b31f43060e8c16ea5a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -70,6 +70,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #15036: Allow removing or changing multiple items in
+  single-file mailboxes (mbox, MMDF, Babyl) flushing the mailbox
+  between the changes.
+
 - Issue #10133: Make multiprocessing deallocate buffer if socket read
   fails.  Patch by Hallvard B Furuseth.