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 eric.frederich
Recipients eric.frederich
Date 2021-03-17.15:23:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615994616.04.0.762651186772.issue43529@roundup.psfhosted.org>
In-reply-to
Content
Calling pathlib.Path.glob("**/*) on a directory containing a symlink which resolves to a very long filename causes OSError.

This is completely avoidable since symlinks are not followed anyway.

In pathlib.py, the _RecursiveWildcardSelector has a method _iterate_directories which first calls entry.is_dir() prior to excluding based on entry.is_symlink().

It's the entry.is_dir() which is failing.
If the check for entry.is_symlink() were to happen first this error would be avoided.

It's worth noting that on Linux "ls -l bad_link" works fine.
Also "find /some/path/containing/bad/link" works fine.
You do get an error however when running "ls bad_link"
I believe Python's glob() should act like "find" on Linux and not fail.
Because it is explicitly ignoring symlinks anyway, it has no business calling is_dir() on a symlink.

I have attached a file which reproduces this problem.  It's meant to be ran inside of an empty directory.
History
Date User Action Args
2021-03-17 15:23:36eric.frederichsetrecipients: + eric.frederich
2021-03-17 15:23:36eric.frederichsetmessageid: <1615994616.04.0.762651186772.issue43529@roundup.psfhosted.org>
2021-03-17 15:23:36eric.frederichlinkissue43529 messages
2021-03-17 15:23:35eric.frederichcreate