File tree 1 file changed +11
-4
lines changed 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 27
27
import os
28
28
import sys
29
29
import warnings
30
+
31
+ if sys .version_info [0 ] == 3 and sys .version_info [1 ] >= 3 :
32
+ import importlib .machinery
33
+ SUFFIXES = importlib .machinery .all_suffixes ()
34
+ else :
35
+ SUFFIXES = [suffix for suffix , mode , type in imp .get_suffixes ()]
36
+
30
37
try :
31
38
from warnings import catch_warnings
32
39
except ImportError :
@@ -124,17 +131,17 @@ def find_modules(path):
124
131
except EnvironmentError :
125
132
filenames = []
126
133
for name in filenames :
127
- if not any (name .endswith (suffix [ 0 ] ) for suffix in imp . get_suffixes () ):
134
+ if not any (name .endswith (suffix ) for suffix in SUFFIXES ):
128
135
# Possibly a package
129
136
if '.' in name :
130
137
continue
131
138
elif os .path .isdir (os .path .join (path , name )):
132
139
# Unfortunately, CPython just crashes if there is a directory
133
140
# which ends with a python extension, so work around.
134
141
continue
135
- for suffix in imp . get_suffixes () :
136
- if name .endswith (suffix [ 0 ] ):
137
- name = name [:- len (suffix [ 0 ] )]
142
+ for suffix in SUFFIXES :
143
+ if name .endswith (suffix ):
144
+ name = name [:- len (suffix )]
138
145
break
139
146
if py3 and name == "badsyntax_pep3120" :
140
147
# Workaround for issue #166
You can’t perform that action at this time.
0 commit comments