Title: pathlib.Path.glob does not follow symlinks
Type: behavior Stage:
Components: Library (Lib), Windows Versions: Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: brianmsheldon, emilyemorehouse, jreese, paul.moore, pitrou, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2018-05-05 06:23 by brianmsheldon, last changed 2018-05-17 01:53 by brianmsheldon.

Messages (3)
msg316197 - (view) Author: Brian Sheldon (brianmsheldon) Date: 2018-05-05 06:23
Given a `pathlib.Path` that contains symlinked subfolders, `Path.glob` (and `.rglob`) do not follow symlinks.  This is not consistent with `glob.glob` which does.

For example given the following:
C:\Folder\Subfolder -> D:\Subfolder

`pathlib.Path('C:/Folder').glob('**/*')` yields the following paths:

`glob.glob('C:/Folder/**/*')` yields the following paths:

Notice how the contents of Subfolder are present in the `glob.glob` results but not for `Path.glob`.

I would expect `Path.glob` to be consistent with `glob.glob`.  This is not the only inconsistency (e.g. #22276, #31202) and perhaps `Path.glob` should be re-implemented using `glob.glob`.
msg316724 - (view) Author: John Reese (jreese) * Date: 2018-05-15 20:54
This looks like an issue specific to Windows?  I can't replicate on Mac, and given Windows' method of implementing "symlinks" as junctions.
msg316880 - (view) Author: Brian Sheldon (brianmsheldon) Date: 2018-05-17 01:53
Windows does not implement symlinks as junctions.  Windows has hardlinks, symlinks and junctions which are all distinctly different in behaviour.

I don't doubt that this is a Windows-specific issue, although I have not tested other platforms.  Path.glob and .rglob does work for junctions and hardlinks but glob.glob works consistently for all three.
Date User Action Args
2018-05-17 01:53:56brianmsheldonsetmessages: + msg316880
2018-05-15 20:54:50jreesesetnosy: + jreese
messages: + msg316724
2018-05-05 06:48:21brianmsheldonsettype: behavior
2018-05-05 06:23:00brianmsheldoncreate