Author lordmauve
Recipients lordmauve, pitrou, rbu, serhiy.storchaka
Date 2018-07-17.14:07:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531836461.41.0.56676864532.issue33123@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-07-17 14:07:41lordmauvesetrecipients: + lordmauve, pitrou, serhiy.storchaka, rbu
2018-07-17 14:07:41lordmauvesetmessageid: <1531836461.41.0.56676864532.issue33123@psf.upfronthosting.co.za>
2018-07-17 14:07:41lordmauvelinkissue33123 messages
2018-07-17 14:07:41lordmauvecreate