[Python-checkins] r52478 - in python/trunk/Lib: mailbox.py test/test_mailbox.py

andrew.kuchling python-checkins at python.org
Fri Oct 27 18:55:34 CEST 2006


Author: andrew.kuchling
Date: Fri Oct 27 18:55:34 2006
New Revision: 52478

Modified:
   python/trunk/Lib/mailbox.py
   python/trunk/Lib/test/test_mailbox.py
Log:
[Bug #1575506] The _singlefileMailbox class was using the wrong file object in its flush() method, causing an error

Modified: python/trunk/Lib/mailbox.py
==============================================================================
--- python/trunk/Lib/mailbox.py	(original)
+++ python/trunk/Lib/mailbox.py	Fri Oct 27 18:55:34 2006
@@ -578,7 +578,7 @@
         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."""

Modified: python/trunk/Lib/test/test_mailbox.py
==============================================================================
--- python/trunk/Lib/test/test_mailbox.py	(original)
+++ python/trunk/Lib/test/test_mailbox.py	Fri Oct 27 18:55:34 2006
@@ -747,6 +747,22 @@
         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):
 


More information about the Python-checkins mailing list