]> granicus.if.org Git - python/commitdiff
[Bug #1575506] The _singlefileMailbox class was using the wrong file object in its...
authorAndrew M. Kuchling <amk@amk.ca>
Fri, 27 Oct 2006 16:57:44 +0000 (16:57 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Fri, 27 Oct 2006 16:57:44 +0000 (16:57 +0000)
Lib/mailbox.py
Lib/test/test_mailbox.py
Misc/NEWS

index b72128b4db42f4e1ed418056a9e1f74373f26ba9..eab03afb7c90ebc7aa186c24b0a10e0ed15c79d1 100755 (executable)
@@ -578,7 +578,7 @@ class _singlefileMailbox(Mailbox):
         self._toc = new_toc
         self._pending = False
         if self._locked:
-            _lock_file(new_file, dotlock=False)
+            _lock_file(self._file, dotlock=False)
 
     def _pre_mailbox_hook(self, f):
         """Called before writing the mailbox to file f."""
index 6cdc441ee2e186cf5e24a94987319d9194083968..40cf1929056dde2bf2daac0a76ccc5537294c6c1 100644 (file)
@@ -747,6 +747,22 @@ class _TestMboxMMDF(TestMailbox):
         self._box.lock()
         self._box.unlock()
 
+    def test_relock(self):
+        # Test case for bug #1575506: the mailbox class was locking the
+        # wrong file object in its flush() method.
+        msg = "Subject: sub\n\nbody\n"
+        key1 = self._box.add(msg)
+        self._box.flush()
+        self._box.close()
+        
+        self._box = self._factory(self._path)
+        self._box.lock()
+        key2 = self._box.add(msg)
+        self._box.flush()
+        self.assert_(self._box._locked)
+        self._box.close()
+        
+        
 
 class TestMbox(_TestMboxMMDF):
 
index 13f52a78e7b5c6a634430cd595908e75d01fc662..64fa7bf826e34c1754eb3f2a9ea8009864e7c42b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -105,6 +105,9 @@ Library
 - Bug #1565661: in webbrowser, split() the command for the default
   GNOME browser in case it is a command with args.
 
+- Bug #1575506: Single-file mailboxes didn't re-lock properly in
+  their flush() method.
+
 - Bug #1576241: fix functools.wraps() to work on built-in functions.
 
 - Fix a bug in traceback.format_exception_only() that led to an error