Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/akulakov'closed_at=Nonecreated_at=<Date2021-10-25.19:20:55.106>labels= ['type-bug', 'library', '3.9', '3.10', '3.11']
title='pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename'updated_at=<Date2022-01-23.06:57:12.913>user='https://github.com/raek'
The issue is that _PreciseSelector follows the symlink when it checks if a path exists before yielding it as a result.
I've put up a PR with a fix; I've also added a follow_symlinks arg to exists() method because it seems more logical to be able to test if a path exists via the same method rather than having to also remember and to check for it being a symlink.
I will add docs and news a bit later today or tomorrow.
changed the title [-]pathlib.Path.glob() does not list dangling symlink when pattern is the exact filenane[/-][+]pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename[/+]on Jan 23, 2022
changed the title [-]pathlib.Path.glob() does not list dangling symlink when pattern is the exact filenane[/-][+]pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename[/+]on Jan 23, 2022
Activity
raek commented on Oct 25, 2021
Create a symlink that points to file that doesn't exist:
Then try to glob for that symlink from Python using pathlib:
python3 >>> import pathlib >>> list(pathlib.Path(".").glob("my_symlink")) [] >>> list(pathlib.Path(".").glob("my_symlink*")) [PosixPath('my_symlink')]I'm a bit surprised that these two globs do not return the same results. Personally I would expect both to find the symlink.
Is this behaviour a bug or is it intentional?
akulakov commented on Nov 20, 2021
The issue is that _PreciseSelector follows the symlink when it checks if a path exists before yielding it as a result.
I've put up a PR with a fix; I've also added a follow_symlinks arg to exists() method because it seems more logical to be able to test if a path exists via the same method rather than having to also remember and to check for it being a symlink.
I will add docs and news a bit later today or tomorrow.
akulakov commented on Nov 20, 2021
Rasmus: thanks for the report, it does seem like a bug to me.
3 remaining items
GH-89769: `pathlib.Path.glob()`: do not follow symlinks when checking…
barneygale commented on May 3, 2023
Fixed in 3.12: #29655 / af886ff