@@ -142,25 +142,21 @@ def _select_from(self, parent_path, scandir):
142142 # avoid exhausting file descriptors when globbing deep trees.
143143 with scandir (parent_path ) as scandir_it :
144144 entries = list (scandir_it )
145+ except OSError :
146+ pass
147+ else :
145148 for entry in entries :
146149 if self .dironly :
147150 try :
148- # "entry.is_dir()" can raise PermissionError
149- # in some cases (see bpo-38894), which is not
150- # among the errors ignored by _ignore_error()
151151 if not entry .is_dir ():
152152 continue
153- except OSError as e :
154- if not _ignore_error (e ):
155- raise
153+ except OSError :
156154 continue
157155 name = entry .name
158156 if self .match (name ):
159157 path = parent_path ._make_child_relpath (name )
160158 for p in self .successor ._select_from (path , scandir ):
161159 yield p
162- except PermissionError :
163- return
164160
165161
166162class _RecursiveWildcardSelector (_Selector ):
@@ -175,28 +171,25 @@ def _iterate_directories(self, parent_path, scandir):
175171 # avoid exhausting file descriptors when globbing deep trees.
176172 with scandir (parent_path ) as scandir_it :
177173 entries = list (scandir_it )
174+ except OSError :
175+ pass
176+ else :
178177 for entry in entries :
179178 entry_is_dir = False
180179 try :
181180 entry_is_dir = entry .is_dir (follow_symlinks = False )
182- except OSError as e :
183- if not _ignore_error (e ):
184- raise
181+ except OSError :
182+ pass
185183 if entry_is_dir :
186184 path = parent_path ._make_child_relpath (entry .name )
187185 for p in self ._iterate_directories (path , scandir ):
188186 yield p
189- except PermissionError :
190- return
191187
192188 def _select_from (self , parent_path , scandir ):
193- try :
194- successor_select = self .successor ._select_from
195- for starting_point in self ._iterate_directories (parent_path , scandir ):
196- for p in successor_select (starting_point , scandir ):
197- yield p
198- except PermissionError :
199- return
189+ successor_select = self .successor ._select_from
190+ for starting_point in self ._iterate_directories (parent_path , scandir ):
191+ for p in successor_select (starting_point , scandir ):
192+ yield p
200193
201194
202195class _DoubleRecursiveWildcardSelector (_RecursiveWildcardSelector ):
0 commit comments