Daniel Pope <[email protected]> added the comment:
This would be a shortcut in the common case that you simply want an idempotent
"make sure this file/symlink is gone" operation.
There are already boolean options to enable idempotent behaviour in several
pathlib implementations, such as mkdir(exist_ok=True) and touch(exist_ok=True).
write_bytes() and write_text() are also idempotent. unlink() aligns well with
this.
Because this operation doesn't exist, developers are tempted to write
if path.exists():
path.unlink()
which both has a TOCTTOU bug and doesn't correctly handle symlinks.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33123>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com