summaryrefslogtreecommitdiff
path: root/Lib/pathlib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2016-01-07 10:57:37 -0800
committerGuido van Rossum <guido@python.org>2016-01-07 10:57:37 -0800
commitc3a8272705f26499d522ddda8ef0f07f8efcee40 (patch)
treefc3736cca0e539d525377ef7f91792cbae649573 /Lib/pathlib.py
parent16fb6748820c72123239c0f326e141a14cf39f85 (diff)
parentbc9fddaf50df55f1b4d11ecb5598b95adacac707 (diff)
downloadcpython-git-c3a8272705f26499d522ddda8ef0f07f8efcee40.tar.gz
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.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index a1e0a822d2..bbac773228 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: