File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 2626import os
2727import sys
2828import 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+
2936try :
3037 from warnings import catch_warnings
3138except ImportError :
@@ -119,17 +126,17 @@ def find_modules(path):
119126 except EnvironmentError :
120127 filenames = []
121128 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 ):
123130 # Possibly a package
124131 if '.' in name :
125132 continue
126133 elif os .path .isdir (os .path .join (path , name )):
127134 # Unfortunately, CPython just crashes if there is a directory
128135 # which ends with a python extension, so work around.
129136 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 )]
133140 break
134141 if py3 and name == "badsyntax_pep3120" :
135142 # Workaround for issue #166
You can’t perform that action at this time.
0 commit comments