Message300424
On Windows (Windows 10 in my case), given the following directory structure:
- rootfolder
- a
- b
- junc (directory junction to ../a)
a call to `shutil.rmtree('root')` will fail with an exception `FileNotFoundError: [WinError 3]`, in a call to `os.listdir()` in `_rmtree_unsafe`. See attached minimal working example.
Note that sorting order is important: A link in 'a' pointing to 'b' does not fail. This is because `os.listdir()` raises an exception for 'b/junc' when its target ('a') has already been deleted.
Also, note that this is only for junctions, not directory links (`mklink /J` vs `mklink /D`), because:
- Directory links flag false in the `stat.S_ISDIR(os.lstat('b/junc').st_mode)` test while junctions do not.
- `os.islink()` returns false for both junctions, while directory links do not.
Indicated Python versions are those which I have personally tested on, and observed this behavior.
Current use case: Deleting a folder tree generated by an external tool, which creates junction links as part of its normal operation ('lerna' tool for the 'npm' javascript package manager). |
|
Date |
User |
Action |
Args |
2017-08-17 13:58:18 | vidartf | set | recipients:
+ vidartf, paul.moore, tim.golden, zach.ware, steve.dower |
2017-08-17 13:58:18 | vidartf | set | messageid: <1502978298.87.0.60982184572.issue31226@psf.upfronthosting.co.za> |
2017-08-17 13:58:18 | vidartf | link | issue31226 messages |
2017-08-17 13:58:17 | vidartf | create | |
|