Author Nirbheek Chauhan
Recipients Nirbheek Chauhan, neologix, paul.moore, r.david.murray, zach.ware
Date 2016-05-19.05:01:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463634084.76.0.0235976137605.issue22040@psf.upfronthosting.co.za>
In-reply-to
Content
> In other words, on unix shutil.rmtree is *already* 'rm -rf'.

This is not true. See:

  $ mkdir testdir && chmod 200 testdir && ls -lhd testdir
  d-w------- 2 nirbheek nirbheek 4.0K May 19 10:21 testdir

`rm -rf` works fine on this. But shutil.rmtree borks:

$ python3 -c 'import shutil; shutil.rmtree("testdir")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.5/shutil.py", line 470, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/usr/lib64/python3.5/shutil.py", line 468, in rmtree
    fd = os.open(path, os.O_RDONLY)
PermissionError: [Errno 13] Permission denied: 'testdir'

The -f option to `rm` ensures that it tries its hardest to resolve permissions problems and does not error out if it can't resolve them either. The latter is available via 'ignore_errors', but the former is a missing feature. A shutil.rmtree flag that 'resolves permissions' would be useful on all platforms. Not just Windows.
History
Date User Action Args
2016-05-19 05:01:24Nirbheek Chauhansetrecipients: + Nirbheek Chauhan, paul.moore, r.david.murray, neologix, zach.ware
2016-05-19 05:01:24Nirbheek Chauhansetmessageid: <1463634084.76.0.0235976137605.issue22040@psf.upfronthosting.co.za>
2016-05-19 05:01:24Nirbheek Chauhanlinkissue22040 messages
2016-05-19 05:01:23Nirbheek Chauhancreate