File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -191,8 +191,11 @@ def iter_modules(self, prefix=''):
191191
192192 yielded = {}
193193 import inspect
194-
195- filenames = os .listdir (self .path )
194+ try :
195+ filenames = os .listdir (self .path )
196+ except OSError :
197+ # ignore unreadable directories like import does
198+ filenames = []
196199 filenames .sort () # handle packages before same-named modules
197200
198201 for fn in filenames :
@@ -205,7 +208,12 @@ def iter_modules(self, prefix=''):
205208
206209 if not modname and os .path .isdir (path ) and '.' not in fn :
207210 modname = fn
208- for fn in os .listdir (path ):
211+ try :
212+ dircontents = os .listdir (path )
213+ except OSError :
214+ # ignore unreadable directories like import does
215+ dircontents = []
216+ for fn in dircontents :
209217 subname = inspect .getmodulename (fn )
210218 if subname == '__init__' :
211219 ispkg = True
You can’t perform that action at this time.
0 commit comments