Message392185
I wrote PR 25684 to fix this issue.
> What does os.rename do on Linux? Does it just overwrite existing files by default?
os.rename() calls rename():
https://man7.org/linux/man-pages/man2/rename.2.html
rename() renames a file, moving it between directories if
required. Any other hard links to the file (as created using
link(2)) are unaffected. Open file descriptors for oldpath are
also unaffected.
If newpath already exists, it will be atomically replaced, so
that there is no point at which another process attempting to
access newpath will find it missing. However, there will
probably be a window in which both oldpath and newpath refer to
the file being renamed.
On Windows, os.rename() is implemented with MoveFileExW(src, dst, 0).
Maybe the test should use os.replace() instead of os.rename()? On Windows, os.replace() is implemented with with MoveFileExW(src, dst, MOVEFILE_REPLACE_EXISTING).
HandlerWithNamerAndRotator.rotator() of test_logging calls os.rename() when the file already exists:
if os.path.exists(source):
os.rename(source, dest + ".rotated")
And the test fails with "Cannot create a file when that file already exists"... well yes, we just tested that it exists. |
|
Date |
User |
Action |
Args |
2021-04-28 11:24:18 | vstinner | set | recipients:
+ vstinner, paul.moore, vinay.sajip, tim.golden, zach.ware, steve.dower |
2021-04-28 11:24:18 | vstinner | set | messageid: <1619609058.46.0.932540744329.issue43961@roundup.psfhosted.org> |
2021-04-28 11:24:18 | vstinner | link | issue43961 messages |
2021-04-28 11:24:17 | vstinner | create | |
|