This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients bignose, eryksun, ethan.furman, georg.brandl, gumnos, r.david.murray, serhiy.storchaka
Date 2017-05-01.23:04:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493679887.5.0.656808414435.issue26362@psf.upfronthosting.co.za>
In-reply-to
Content
> the lack of Windows' os.rename() atomicity

rename/replace is two system calls: NtOpenFile to get a handle for the source file and NtSetInformationFile to rename it. The difference is only that replace() sets the ReplaceIfExists field in the FileRenameInformation. The rename operation should be atomic.

If the source file is already open without delete/rename sharing, opening it to rename it will fail with sharing violation. After the handle is open, another thread could set the delete disposition on the source file (i.e. flag it to be unlinked), which will cause the rename to fail with access denied. The relative timing of the threads is the difference between getting a FileNotFoundError versus a PermissionError. The other thread could also open a handle to the destination file at this point, which also causes the rename to fail with access denied, but that's no different from what would happen if it were already open.
History
Date User Action Args
2017-05-01 23:04:47eryksunsetrecipients: + eryksun, georg.brandl, gumnos, r.david.murray, ethan.furman, bignose, serhiy.storchaka
2017-05-01 23:04:47eryksunsetmessageid: <1493679887.5.0.656808414435.issue26362@psf.upfronthosting.co.za>
2017-05-01 23:04:47eryksunlinkissue26362 messages
2017-05-01 23:04:47eryksuncreate