[Python-checkins] r88408 - in python/branches/release27-maint: Lib/mailbox.py

r.david.murray python-checkins at python.org
Sat Feb 12 03:03:56 CET 2011


Author: r.david.murray
Date: Sat Feb 12 03:03:56 2011
New Revision: 88408
Log:
Merged revisions 88407 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
 r88407 | r.david.murray | 2011年02月11日 19:03:31 -0500 (2011年2月11日) | 2 lines
 
 Fix #11116 fix on Windows (close file before removing in MH code)
........
Modified:
 python/branches/release27-maint/ (props changed)
 python/branches/release27-maint/Lib/mailbox.py
Modified: python/branches/release27-maint/Lib/mailbox.py
==============================================================================
--- python/branches/release27-maint/Lib/mailbox.py	(original)
+++ python/branches/release27-maint/Lib/mailbox.py	Sat Feb 12 03:03:56 2011
@@ -876,6 +876,7 @@
 new_key = max(keys) + 1
 new_path = os.path.join(self._path, str(new_key))
 f = _create_carefully(new_path)
+ closed = False
 try:
 if self._locked:
 _lock_file(f)
@@ -883,6 +884,11 @@
 try:
 self._dump_message(message, f)
 except BaseException:
+ # Unlock and close so it can be deleted on Windows
+ if self._locked:
+ _unlock_file(f)
+ _sync_close(f)
+ closed = True
 os.remove(new_path)
 raise
 if isinstance(message, MHMessage):
@@ -891,7 +897,8 @@
 if self._locked:
 _unlock_file(f)
 finally:
- _sync_close(f)
+ if not closed:
+ _sync_close(f)
 return new_key
 
 def remove(self, key):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /