[Python-checkins] r78332 - in python/trunk/Lib: mailbox.py test/test_mailbox.py
andrew.kuchling
python-checkins at python.org
Mon Feb 22 19:42:07 CET 2010
Author: andrew.kuchling
Date: Mon Feb 22 19:42:07 2010
New Revision: 78332
Log:
#7627: MH.remove() would fail if the MH mailbox was locked;
it would call _unlock_file() and pass it a closed file object. Noted by Rob Austein.
Modified:
python/trunk/Lib/mailbox.py
python/trunk/Lib/test/test_mailbox.py
Modified: python/trunk/Lib/mailbox.py
==============================================================================
--- python/trunk/Lib/mailbox.py (original)
+++ python/trunk/Lib/mailbox.py Mon Feb 22 19:42:07 2010
@@ -892,17 +892,9 @@
raise KeyError('No message with key: %s' % key)
else:
raise
- try:
- if self._locked:
- _lock_file(f)
- try:
- f.close()
- os.remove(os.path.join(self._path, str(key)))
- finally:
- if self._locked:
- _unlock_file(f)
- finally:
+ else:
f.close()
+ os.remove(path)
def __setitem__(self, key, message):
"""Replace the keyed message; raise KeyError if it doesn't exist."""
Modified: python/trunk/Lib/test/test_mailbox.py
==============================================================================
--- python/trunk/Lib/test/test_mailbox.py (original)
+++ python/trunk/Lib/test/test_mailbox.py Mon Feb 22 19:42:07 2010
@@ -979,6 +979,13 @@
key0 = self._box.add(msg0)
refmsg0 = self._box.get_message(key0)
+ def test_issue7627(self):
+ msg0 = mailbox.MHMessage(self._template % 0)
+ key0 = self._box.add(msg0)
+ self._box.lock()
+ self._box.remove(key0)
+ self._box.unlock()
+
def test_pack(self):
# Pack the contents of the mailbox
msg0 = mailbox.MHMessage(self._template % 0)
More information about the Python-checkins
mailing list