This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vidartf
Recipients paul.moore, steve.dower, tim.golden, vidartf, zach.ware
Date 2017-08-17.13:58:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1502978298.87.0.60982184572.issue31226@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2017-08-17 13:58:18vidartfsetrecipients: + vidartf, paul.moore, tim.golden, zach.ware, steve.dower
2017-08-17 13:58:18vidartfsetmessageid: <1502978298.87.0.60982184572.issue31226@psf.upfronthosting.co.za>
2017-08-17 13:58:18vidartflinkissue31226 messages
2017-08-17 13:58:17vidartfcreate