STINNER Victor <vstin...@python.org> added the comment:
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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43961> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com