GH-87695: Fix OSError from pathlib.Path.glob() (GH-104292)

Fix issue where `pathlib.Path.glob()` raised `OSError` when it encountered
a symlink to an overly long path.
This commit is contained in:
Barney Gale 2023-05-10 18:17:08 +01:00 committed by GitHub
parent 7a3b03509e
commit a33ce66dca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -178,11 +178,11 @@ class _RecursiveWildcardSelector(_Selector):
for entry in entries:
entry_is_dir = False
try:
entry_is_dir = entry.is_dir()
entry_is_dir = entry.is_dir(follow_symlinks=False)
except OSError as e:
if not _ignore_error(e):
raise
if entry_is_dir and not entry.is_symlink():
if entry_is_dir:
path = parent_path._make_child_relpath(entry.name)
for p in self._iterate_directories(path, scandir):
yield p