summaryrefslogtreecommitdiffstats
path: root/Lib/mailbox.py
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2012-06-29 12:09:12 (GMT)
committerPetri Lehtinen <petri@digip.org>2012-06-29 12:09:16 (GMT)
commitd07de404907b7eab1796b9065ff6bcc3de14c4fc (patch)
treefc5acfe4e6ce4f79754d8b73aa870de17491c9ac /Lib/mailbox.py
parent4e6e5a06bbdba83389510331f5b0f2047e21ccd5 (diff)
downloadcpython-d07de404907b7eab1796b9065ff6bcc3de14c4fc.zip
cpython-d07de404907b7eab1796b9065ff6bcc3de14c4fc.tar.gz
cpython-d07de404907b7eab1796b9065ff6bcc3de14c4fc.tar.bz2
#5346: Preserve permissions of mbox, MMDF and Babyl mailbox files on flush()
Diffstat (limited to 'Lib/mailbox.py')
-rw-r--r--Lib/mailbox.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index fc154fa..6168367 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -665,6 +665,9 @@ class _singlefileMailbox(Mailbox):
_sync_close(new_file)
# self._file is about to get replaced, so no need to sync.
self._file.close()
+ # Make sure the new file's mode is the same as the old file's
+ mode = os.stat(self._path).st_mode
+ os.chmod(new_file.name, mode)
try:
os.rename(new_file.name, self._path)
except OSError, e: