File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 43
43
44
44
SUFFIXES = importlib .machinery .all_suffixes ()
45
45
else :
46
+ import imp
47
+
46
48
SUFFIXES = [suffix for suffix , mode , type in imp .get_suffixes ()]
47
49
48
50
# The cached list of all known modules
@@ -158,20 +160,23 @@ def find_modules(path):
158
160
# Workaround for issue #166
159
161
continue
160
162
try :
163
+ is_package = False
161
164
with warnings .catch_warnings ():
162
165
warnings .simplefilter ("ignore" , ImportWarning )
163
166
fo , pathname , _ = imp .find_module (name , [path ])
167
+ if fo is not None :
168
+ fo .close ()
169
+ else :
170
+ # Yay, package
171
+ is_package = True
164
172
except (ImportError , IOError , SyntaxError ):
165
173
continue
166
174
except UnicodeEncodeError :
167
175
# Happens with Python 3 when there is a filename in some
168
176
# invalid encoding
169
177
continue
170
178
else :
171
- if fo is not None :
172
- fo .close ()
173
- else :
174
- # Yay, package
179
+ if is_package :
175
180
for subname in find_modules (pathname ):
176
181
if subname != "__init__" :
177
182
yield "%s.%s" % (name , subname )
You can’t perform that action at this time.
0 commit comments