summaryrefslogtreecommitdiffstats
path: root/Lib/mailbox.py
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2012-06-29 12:12:54 (GMT)
committerPetri Lehtinen <petri@digip.org>2012-06-29 12:12:54 (GMT)
commit25652884b452142460f5868ac28af4f12895e046 (patch)
tree51d38f09fcbb7fad851a15383a6ca7e522c0e293 /Lib/mailbox.py
parent31a78c3d6521272c418f5ffbb8824d26be40db50 (diff)
parent5b5619f717be2a712c05d6c63a0ca4184f263aee (diff)
downloadcpython-25652884b452142460f5868ac28af4f12895e046.zip
cpython-25652884b452142460f5868ac28af4f12895e046.tar.gz
cpython-25652884b452142460f5868ac28af4f12895e046.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 4043d74..3ab3396 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -691,6 +691,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 as e: