[issue21876] os.rename(src, dst) does nothing when src and dst files are hard-linked
Eryk Sun
report at bugs.python.org
Wed Nov 17 15:34:15 EST 2021
Eryk Sun <eryksun at gmail.com> added the comment:
> It's nice if os.rename() can be atomic.
How about fixing the behavior in shutil.move()? Currently it tries os.rename(src, dst) without checking for this case. For example:
>>> os.path.samefile('src', 'dst')
True
>>> shutil.move('src', 'dst')
'dst'
>>> os.path.exists('src')
True
>>> os.stat('src').st_nlink
2
---
Note that there's nothing to fix, and not much to document in Windows. It works as expected. A slight difference from the general case is that os.replace() is required only when replacing a different file, not a hard link for the same file.
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue21876>
_______________________________________
More information about the Python-bugs-list
mailing list