diff options
author | Guido van Rossum <guido@python.org> | 2016-01-07 18:57:37 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-01-07 18:57:37 (GMT) |
commit | c3a8272705f26499d522ddda8ef0f07f8efcee40 (patch) | |
tree | fc3736cca0e539d525377ef7f91792cbae649573 /Lib/pathlib.py | |
parent | 16fb6748820c72123239c0f326e141a14cf39f85 (diff) | |
parent | bc9fddaf50df55f1b4d11ecb5598b95adacac707 (diff) | |
download | cpython-c3a8272705f26499d522ddda8ef0f07f8efcee40.zip cpython-c3a8272705f26499d522ddda8ef0f07f8efcee40.tar.gz cpython-c3a8272705f26499d522ddda8ef0f07f8efcee40.tar.bz2 |
Add another try/except PermissionError to avoid depending on listdir order. Fix issues #24120 and #26012. (Merge 3.4->3.5)
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 a1e0a82..bbac773 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -539,11 +539,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: |