mirror of https://github.com/python/cpython
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 (Fri, 11 Feb 2011) | 2 lines Fix #11116 fix on Windows (close file before removing in MH code) ........
This commit is contained in:
parent
008c0448bd
commit
f9e342321a
|
@ -876,6 +876,7 @@ class MH(Mailbox):
|
||||||
new_key = max(keys) + 1
|
new_key = max(keys) + 1
|
||||||
new_path = os.path.join(self._path, str(new_key))
|
new_path = os.path.join(self._path, str(new_key))
|
||||||
f = _create_carefully(new_path)
|
f = _create_carefully(new_path)
|
||||||
|
closed = False
|
||||||
try:
|
try:
|
||||||
if self._locked:
|
if self._locked:
|
||||||
_lock_file(f)
|
_lock_file(f)
|
||||||
|
@ -883,6 +884,11 @@ class MH(Mailbox):
|
||||||
try:
|
try:
|
||||||
self._dump_message(message, f)
|
self._dump_message(message, f)
|
||||||
except BaseException:
|
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)
|
os.remove(new_path)
|
||||||
raise
|
raise
|
||||||
if isinstance(message, MHMessage):
|
if isinstance(message, MHMessage):
|
||||||
|
@ -891,6 +897,7 @@ class MH(Mailbox):
|
||||||
if self._locked:
|
if self._locked:
|
||||||
_unlock_file(f)
|
_unlock_file(f)
|
||||||
finally:
|
finally:
|
||||||
|
if not closed:
|
||||||
_sync_close(f)
|
_sync_close(f)
|
||||||
return new_key
|
return new_key
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue