This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mailbox.MH.remove() lock handling is broken
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, sraustein
Priority: normal Keywords:

Created on 2010-01-04 00:25 by sraustein, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg97185 - (view) Author: Rob Austein (sraustein) Date: 2010-01-04 00:25
.remove() method of MH class in the mailbox module of the standard library references a file object after closing it.  This throws a ValueError exception (I/O operation on closed file).

The f.close() call just before the os.remove() call in the innermost try: block should just be removed, the finally: clause of the outer try: block will clean things up correctly.  As far as I know it is completely legal (if slightly unusual) to delete an open file on any unix-like operating system, and the locking semantics won't work correctly otherwise in any case.
msg99809 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2010-02-22 18:43
Thanks for your bug report!

Unfortunately, the fix isn't quite right, because on Windows you can't delete files that are open.  I think an even simpler fix is just to remove that locking; if self._locked is true, this process presumably has exclusive access to the mailbox and can just go ahead and remove the file.

I've committed this to 2.7 trunk as rev78332.
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 51876
2010-02-22 18:43:20akuchlingsetstatus: open -> closed
resolution: fixed
messages: + msg99809
2010-01-06 15:38:28akuchlingsetassignee: akuchling

nosy: + akuchling
2010-01-04 00:25:10srausteincreate