Issue 7627: mailbox.MH.remove() lock handling is broken (original) (raw)

Issue7627

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:56 admin set github: 51876
2010-02-22 18:43:20 akuchling set status: open -> closedresolution: fixedmessages: +
2010-01-06 15:38:28 akuchling set assignee: akuchlingnosy: + akuchling
2010-01-04 00:25:10 sraustein create