@@ -95,16 +95,6 @@ def _path_split(path):
9595 return front , tail
9696
9797
98- def _path_exists (path ):
99- """Replacement for os.path.exists."""
100- try :
101- _os .stat (path )
102- except OSError :
103- return False
104- else :
105- return True
106-
107-
10898def _path_is_mode_type (path , mode ):
10999 """Test whether the path is the specified mode type."""
110100 try :
@@ -128,28 +118,6 @@ def _path_isdir(path):
128118 return _path_is_mode_type (path , 0o040000 )
129119
130120
131- def _path_without_ext (path , ext_type ):
132- """Replacement for os.path.splitext()[0]."""
133- for suffix in _suffix_list (ext_type ):
134- if path .endswith (suffix ):
135- return path [:- len (suffix )]
136- else :
137- raise ValueError ("path is not of the specified type" )
138-
139-
140- def _path_absolute (path ):
141- """Replacement for os.path.abspath."""
142- if not path :
143- path = _os .getcwd ()
144- try :
145- return _os ._getfullpathname (path )
146- except AttributeError :
147- if path .startswith ('/' ):
148- return path
149- else :
150- return _path_join (_os .getcwd (), path )
151-
152-
153121def _write_atomic (path , data ):
154122 """Best-effort function to write data to a path atomically.
155123 Be prepared to handle a FileExistsError if concurrent writing of the
@@ -338,12 +306,6 @@ def _requires_frozen_wrapper(self, fullname):
338306 return _requires_frozen_wrapper
339307
340308
341- def _suffix_list (suffix_type ):
342- """Return a list of file suffixes based on the imp file type."""
343- return [suffix [0 ] for suffix in _imp .get_suffixes ()
344- if suffix [2 ] == suffix_type ]
345-
346-
347309# Loaders #####################################################################
348310
349311class BuiltinImporter :
@@ -1196,8 +1158,9 @@ def _install(sys_module, _imp_module):
11961158
11971159 """
11981160 _setup (sys_module , _imp_module )
1199- supported_loaders = [(ExtensionFileLoader , _suffix_list (3 ), False ),
1200- (SourceFileLoader , _suffix_list (1 ), True ),
1201- (SourcelessFileLoader , _suffix_list (2 ), True )]
1161+ extensions = ExtensionFileLoader , _imp_module .extension_suffixes (), False
1162+ source = SourceFileLoader , _SOURCE_SUFFIXES , True
1163+ bytecode = SourcelessFileLoader , [_BYTECODE_SUFFIX ], True
1164+ supported_loaders = [extensions , source , bytecode ]
12021165 sys .path_hooks .extend ([FileFinder .path_hook (* supported_loaders )])
12031166 sys .meta_path .extend ([BuiltinImporter , FrozenImporter , PathFinder ])
0 commit comments