diff options
author | Guido van Rossum <guido@python.org> | 2016-01-07 10:56:36 -0800 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-01-07 10:56:36 -0800 |
commit | bc9fddaf50df55f1b4d11ecb5598b95adacac707 (patch) | |
tree | 51062a47247af062331235be329a1ed1be223f3d /Lib/pathlib.py | |
parent | f3695bfacfa51e0e8fb47c7e406152a3f9cd3af2 (diff) | |
download | cpython-git-bc9fddaf50df55f1b4d11ecb5598b95adacac707.tar.gz |
Add another try/except PermissionError to avoid depending on listdir order. Fix issues #24120 and #26012.
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 1bd457a487..8fef2590b8 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -494,11 +494,14 @@ class _RecursiveWildcardSelector(_Selector): def _iterate_directories(self, parent_path, is_dir, listdir): yield parent_path - for name in listdir(parent_path): - path = parent_path._make_child_relpath(name) - if is_dir(path) and not path.is_symlink(): - for p in self._iterate_directories(path, is_dir, listdir): - yield p + try: + for name in listdir(parent_path): + path = parent_path._make_child_relpath(name) + if is_dir(path) and not path.is_symlink(): + for p in self._iterate_directories(path, is_dir, listdir): + yield p + except PermissionError: + return def _select_from(self, parent_path, is_dir, exists, listdir): try: |