From: Andrew M. Kuchling Date: Fri, 27 Oct 2006 16:55:34 +0000 (+0000) Subject: [Bug #1575506] The _singlefileMailbox class was using the wrong file object in its... X-Git-Tag: v2.6a1~2521 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f87183cf58374f04d12d46c7b885b4a3eaec177;p=python [Bug #1575506] The _singlefileMailbox class was using the wrong file object in its flush() method, causing an error --- diff --git a/Lib/mailbox.py b/Lib/mailbox.py index b72128b4db..eab03afb7c 100755 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -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.""" diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index 6cdc441ee2..40cf192905 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -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):