mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
#5346: Preserve permissions of mbox, MMDF and Babyl mailbox files on flush()
This commit is contained in:
commit
25652884b4
3 changed files with 23 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue