We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7ecd55d commit f3b6df8Copy full SHA for f3b6df8
Lib/mailbox.py
@@ -750,9 +750,13 @@ def flush(self):
750
_sync_close(new_file)
751
# self._file is about to get replaced, so no need to sync.
752
self._file.close()
753
- # Make sure the new file's mode is the same as the old file's
754
- mode = os.stat(self._path).st_mode
755
- os.chmod(new_file.name, mode)
+ # Make sure the new file's mode and owner are the same as the old file's
+ info = os.stat(self._path)
+ os.chmod(new_file.name, info.st_mode)
756
+ try:
757
+ os.chown(new_file.name, info.st_uid, info.st_gid)
758
+ except:
759
+ pass
760
try:
761
os.rename(new_file.name, self._path)
762
except FileExistsError:
0 commit comments