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