reopen 313644 thanks The patch has a race condition. The file can be opened before the permissions have been adjusted. You must create it in a restrict directory, or use os.open with an appropriate mode, or temporarily restrict the umask.