Issue33428
Created on 2018-05-05 06:23 by brianmsheldon, last changed 2022-04-11 14:59 by admin.
| Messages (4) | |||
|---|---|---|---|
| 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
C:\Folder\Subfolder -> D:\Subfolder
D:\Subfolder\File.txt
`pathlib.Path('C:/Folder').glob('**/*')` yields the following paths:
WindowsPath('C:/Folder/Subfolder')
`glob.glob('C:/Folder/**/*')` yields the following paths:
'C:/Folder\\Subfolder'
'C:/Folder\\Subfolder\\File.txt'
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. |
|||
| msg367640 - (view) | Author: Danya Alexeyevsky (Danya.Alexeyevsky) | Date: 2020-04-29 11:12 | |
I can reproduce the bug with Linux and python 3.7.5:
```
Python 3.7.5 (default, Apr 19 2020, 20:18:17)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> Path('a/b').mkdir(parents=True)
>>> Path('c/d').mkdir(parents=True)
>>> Path('a/c').symlink_to('../c')
>>> Path('e').symlink_to('c')
>>> list(Path('.').rglob('*'))
[PosixPath('e'), PosixPath('c'), PosixPath('a'), PosixPath('c/d'), PosixPath('a/c'), PosixPath('a/b')]
```
Expected result:
```
[PosixPath('e'), PosixPath('e/d'), PosixPath('c'), PosixPath('a'), PosixPath('c/d'), PosixPath('a/c'), PosixPath('a/c/d'), PosixPath('a/b')]
```
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:00 | admin | set | github: 77609 |
| 2020-04-29 11:12:49 | Danya.Alexeyevsky | set | nosy:
+ Danya.Alexeyevsky messages: + msg367640 |
| 2018-05-17 01:53:56 | brianmsheldon | set | messages: + msg316880 |
| 2018-05-15 20:54:50 | jreese | set | nosy:
+ jreese messages: + msg316724 |
| 2018-05-05 06:48:21 | brianmsheldon | set | type: behavior |
| 2018-05-05 06:23:00 | brianmsheldon | create | |