Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 1 | """Abstract base classes related to import.""" |
| 2 | from . import _bootstrap |
| 3 | from . import machinery |
Brett Cannon | 938d44d | 2012-04-22 19:58:33 -0400 | [diff] [blame] | 4 | try: |
| 5 | import _frozen_importlib |
Brett Cannon | cd171c8 | 2013-07-04 17:43:24 -0400 | [diff] [blame] | 6 | except ImportError as exc: |
Brett Cannon | 938d44d | 2012-04-22 19:58:33 -0400 | [diff] [blame] | 7 | if exc.name != '_frozen_importlib': |
| 8 | raise |
| 9 | _frozen_importlib = None |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 10 | import abc |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 11 | |
| 12 | |
Brett Cannon | 938d44d | 2012-04-22 19:58:33 -0400 | [diff] [blame] | 13 | def _register(abstract_cls, *classes): |
| 14 | for cls in classes: |
| 15 | abstract_cls.register(cls) |
| 16 | if _frozen_importlib is not None: |
| 17 | frozen_cls = getattr(_frozen_importlib, cls.__name__) |
| 18 | abstract_cls.register(frozen_cls) |
| 19 | |
| 20 | |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 21 | class Finder(metaclass=abc.ABCMeta): |
| 22 | |
Brett Cannon | f4dc920 | 2012-08-10 12:21:12 -0400 | [diff] [blame] | 23 | """Legacy abstract base class for import finders. |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 24 | |
Brett Cannon | f4dc920 | 2012-08-10 12:21:12 -0400 | [diff] [blame] | 25 | It may be subclassed for compatibility with legacy third party |
| 26 | reimplementations of the import system. Otherwise, finder |
| 27 | implementations should derive from the more specific MetaPathFinder |
| 28 | or PathEntryFinder ABCs. |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 29 | """ |
| 30 | |
Brett Cannon | f4dc920 | 2012-08-10 12:21:12 -0400 | [diff] [blame] | 31 | @abc.abstractmethod |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 32 | def find_module(self, fullname, path=None): |
Brett Cannon | f4dc920 | 2012-08-10 12:21:12 -0400 | [diff] [blame] | 33 | """An abstract method that should find a module. |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 34 | The fullname is a str and the optional path is a str or None. |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 35 | Returns a Loader object or None. |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 36 | """ |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 37 | |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 38 | |
| 39 | class MetaPathFinder(Finder): |
| 40 | |
| 41 | """Abstract base class for import finders on sys.meta_path.""" |
| 42 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 43 | # We don't define find_spec() here since that would break |
| 44 | # hasattr checks we do to support backward compatibility. |
| 45 | |
| 46 | # XXX Deprecate |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 47 | def find_module(self, fullname, path): |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 48 | """Return a loader for the module. |
| 49 | |
| 50 | If no module is found, return None. The fullname is a str and |
| 51 | the path is a list of strings or None. |
| 52 | |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 53 | """ |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 54 | return None |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 55 | |
Brett Cannon | f4dc920 | 2012-08-10 12:21:12 -0400 | [diff] [blame] | 56 | def invalidate_caches(self): |
| 57 | """An optional method for clearing the finder's cache, if any. |
| 58 | This method is used by importlib.invalidate_caches(). |
| 59 | """ |
Brett Cannon | f4dc920 | 2012-08-10 12:21:12 -0400 | [diff] [blame] | 60 | |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 61 | _register(MetaPathFinder, machinery.BuiltinImporter, machinery.FrozenImporter, |
Nick Coghlan | ff79486 | 2012-08-02 21:45:24 +1000 | [diff] [blame] | 62 | machinery.PathFinder, machinery.WindowsRegistryFinder) |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 63 | |
| 64 | |
| 65 | class PathEntryFinder(Finder): |
| 66 | |
| 67 | """Abstract base class for path entry finders used by PathFinder.""" |
| 68 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 69 | # We don't define find_spec() here since that would break |
| 70 | # hasattr checks we do to support backward compatibility. |
| 71 | |
| 72 | # XXX Deprecate. |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 73 | def find_loader(self, fullname): |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 74 | """Return (loader, namespace portion) for the path entry. |
| 75 | |
| 76 | The fullname is a str. The namespace portion is a sequence of |
| 77 | path entries contributing to part of a namespace package. The |
| 78 | sequence may be empty. If loader is not None, the portion will |
| 79 | be ignored. |
| 80 | |
| 81 | The portion will be discarded if another path entry finder |
| 82 | locates the module as a normal module or package. |
| 83 | |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 84 | """ |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 85 | return None, [] |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 86 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 87 | # XXX Deprecate. |
Brett Cannon | f410ce8 | 2012-08-10 17:41:23 -0400 | [diff] [blame] | 88 | find_module = _bootstrap._find_module_shim |
Brett Cannon | f4dc920 | 2012-08-10 12:21:12 -0400 | [diff] [blame] | 89 | |
| 90 | def invalidate_caches(self): |
| 91 | """An optional method for clearing the finder's cache, if any. |
| 92 | This method is used by PathFinder.invalidate_caches(). |
| 93 | """ |
Brett Cannon | f4dc920 | 2012-08-10 12:21:12 -0400 | [diff] [blame] | 94 | |
Nick Coghlan | 8a9080f | 2012-08-02 21:26:03 +1000 | [diff] [blame] | 95 | _register(PathEntryFinder, machinery.FileFinder) |
| 96 | |
| 97 | |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 98 | class Loader(metaclass=abc.ABCMeta): |
| 99 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 100 | """Abstract base class for import loaders.""" |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 101 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 102 | def create_module(self, spec): |
| 103 | """Return a module to initialize and into which to load. |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 104 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 105 | This method should raise ImportError if anything prevents it |
| 106 | from creating a new module. It may return None to indicate |
| 107 | that the spec should create the new module. |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 108 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 109 | create_module() is optional. |
| 110 | |
| 111 | """ |
| 112 | # By default, defer to _SpecMethods.create() for the new module. |
| 113 | return None |
| 114 | |
| 115 | # We don't define exec_module() here since that would break |
| 116 | # hasattr checks we do to support backward compatibility. |
| 117 | |
| 118 | # XXX Deprecate. |
Raymond Hettinger | cd92f37 | 2011-01-13 02:31:25 +0000 | [diff] [blame] | 119 | def load_module(self, fullname): |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 120 | """Return the loaded module. |
| 121 | |
| 122 | The module must be added to sys.modules and have import-related |
| 123 | attributes set properly. The fullname is a str. |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 124 | |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 125 | ImportError is raised on failure. |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 126 | |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 127 | """ |
| 128 | raise ImportError |
| 129 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 130 | # XXX Deprecate. |
Barry Warsaw | d7d2194 | 2012-07-29 16:36:17 -0400 | [diff] [blame] | 131 | def module_repr(self, module): |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 132 | """Return a module's repr. |
| 133 | |
Brett Cannon | f1d7b11 | 2013-05-31 18:39:07 -0400 | [diff] [blame] | 134 | Used by the module type when the method does not raise |
| 135 | NotImplementedError. |
Barry Warsaw | d7d2194 | 2012-07-29 16:36:17 -0400 | [diff] [blame] | 136 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 137 | """ |
| 138 | # The exception will cause ModuleType.__repr__ to ignore this method. |
| 139 | raise NotImplementedError |
Brett Cannon | 0dbb4c7 | 2013-05-31 18:56:47 -0400 | [diff] [blame] | 140 | |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 141 | |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 142 | class ResourceLoader(Loader): |
| 143 | |
Brett Cannon | 7aa21f7 | 2009-03-15 00:53:05 +0000 | [diff] [blame] | 144 | """Abstract base class for loaders which can return data from their |
| 145 | back-end storage. |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 146 | |
| 147 | This ABC represents one of the optional protocols specified by PEP 302. |
| 148 | |
| 149 | """ |
| 150 | |
| 151 | @abc.abstractmethod |
Raymond Hettinger | cd92f37 | 2011-01-13 02:31:25 +0000 | [diff] [blame] | 152 | def get_data(self, path): |
Brett Cannon | 7aa21f7 | 2009-03-15 00:53:05 +0000 | [diff] [blame] | 153 | """Abstract method which when implemented should return the bytes for |
Raymond Hettinger | d958ea7 | 2011-01-13 19:08:04 +0000 | [diff] [blame] | 154 | the specified path. The path must be a str.""" |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 155 | raise IOError |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 156 | |
| 157 | |
| 158 | class InspectLoader(Loader): |
| 159 | |
Brett Cannon | 7aa21f7 | 2009-03-15 00:53:05 +0000 | [diff] [blame] | 160 | """Abstract base class for loaders which support inspection about the |
| 161 | modules they can load. |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 162 | |
| 163 | This ABC represents one of the optional protocols specified by PEP 302. |
| 164 | |
| 165 | """ |
| 166 | |
Raymond Hettinger | cd92f37 | 2011-01-13 02:31:25 +0000 | [diff] [blame] | 167 | def is_package(self, fullname): |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 168 | """Optional method which when implemented should return whether the |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 169 | module is a package. The fullname is a str. Returns a bool. |
| 170 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 171 | Raises ImportError if the module cannot be found. |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 172 | """ |
| 173 | raise ImportError |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 174 | |
Raymond Hettinger | cd92f37 | 2011-01-13 02:31:25 +0000 | [diff] [blame] | 175 | def get_code(self, fullname): |
Brett Cannon | 3b62ca8 | 2013-05-27 21:11:04 -0400 | [diff] [blame] | 176 | """Method which returns the code object for the module. |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 177 | |
Brett Cannon | 3b62ca8 | 2013-05-27 21:11:04 -0400 | [diff] [blame] | 178 | The fullname is a str. Returns a types.CodeType if possible, else |
| 179 | returns None if a code object does not make sense |
| 180 | (e.g. built-in module). Raises ImportError if the module cannot be |
| 181 | found. |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 182 | """ |
Brett Cannon | 3b62ca8 | 2013-05-27 21:11:04 -0400 | [diff] [blame] | 183 | source = self.get_source(fullname) |
| 184 | if source is None: |
| 185 | return None |
| 186 | return self.source_to_code(source) |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 187 | |
| 188 | @abc.abstractmethod |
Raymond Hettinger | cd92f37 | 2011-01-13 02:31:25 +0000 | [diff] [blame] | 189 | def get_source(self, fullname): |
Brett Cannon | 7aa21f7 | 2009-03-15 00:53:05 +0000 | [diff] [blame] | 190 | """Abstract method which should return the source code for the |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 191 | module. The fullname is a str. Returns a str. |
| 192 | |
| 193 | Raises ImportError if the module cannot be found. |
| 194 | """ |
| 195 | raise ImportError |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 196 | |
Brett Cannon | 9ffe85e | 2013-05-26 16:45:10 -0400 | [diff] [blame] | 197 | def source_to_code(self, data, path='<string>'): |
| 198 | """Compile 'data' into a code object. |
| 199 | |
| 200 | The 'data' argument can be anything that compile() can handle. The'path' |
| 201 | argument should be where the data was retrieved (when applicable).""" |
| 202 | return compile(data, path, 'exec', dont_inherit=True) |
| 203 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 204 | exec_module = _bootstrap._LoaderBasics.exec_module |
Brett Cannon | 0dbb4c7 | 2013-05-31 18:56:47 -0400 | [diff] [blame] | 205 | load_module = _bootstrap._LoaderBasics.load_module |
| 206 | |
Eric Snow | b523f84 | 2013-11-22 09:05:39 -0700 | [diff] [blame] | 207 | _register(InspectLoader, machinery.BuiltinImporter, machinery.FrozenImporter) |
Brett Cannon | a113ac5 | 2009-03-15 01:41:33 +0000 | [diff] [blame] | 208 | |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 209 | |
Brett Cannon | 6919427 | 2009-07-20 04:23:48 +0000 | [diff] [blame] | 210 | class ExecutionLoader(InspectLoader): |
| 211 | |
| 212 | """Abstract base class for loaders that wish to support the execution of |
| 213 | modules as scripts. |
| 214 | |
| 215 | This ABC represents one of the optional protocols specified in PEP 302. |
| 216 | |
| 217 | """ |
| 218 | |
| 219 | @abc.abstractmethod |
Raymond Hettinger | cd92f37 | 2011-01-13 02:31:25 +0000 | [diff] [blame] | 220 | def get_filename(self, fullname): |
Brett Cannon | 6919427 | 2009-07-20 04:23:48 +0000 | [diff] [blame] | 221 | """Abstract method which should return the value that __file__ is to be |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 222 | set to. |
| 223 | |
| 224 | Raises ImportError if the module cannot be found. |
| 225 | """ |
| 226 | raise ImportError |
Brett Cannon | 6919427 | 2009-07-20 04:23:48 +0000 | [diff] [blame] | 227 | |
Brett Cannon | 3b62ca8 | 2013-05-27 21:11:04 -0400 | [diff] [blame] | 228 | def get_code(self, fullname): |
| 229 | """Method to return the code object for fullname. |
| 230 | |
| 231 | Should return None if not applicable (e.g. built-in module). |
| 232 | Raise ImportError if the module cannot be found. |
| 233 | """ |
| 234 | source = self.get_source(fullname) |
| 235 | if source is None: |
| 236 | return None |
| 237 | try: |
| 238 | path = self.get_filename(fullname) |
| 239 | except ImportError: |
| 240 | return self.source_to_code(source) |
| 241 | else: |
| 242 | return self.source_to_code(source, path) |
| 243 | |
Eric Snow | 7e70fa5 | 2013-10-04 20:28:52 -0600 | [diff] [blame] | 244 | _register(ExecutionLoader, machinery.ExtensionFileLoader) |
Eric Snow | 5179445 | 2013-10-03 12:08:55 -0600 | [diff] [blame] | 245 | |
Brett Cannon | 6919427 | 2009-07-20 04:23:48 +0000 | [diff] [blame] | 246 | |
Brett Cannon | 938d44d | 2012-04-22 19:58:33 -0400 | [diff] [blame] | 247 | class FileLoader(_bootstrap.FileLoader, ResourceLoader, ExecutionLoader): |
| 248 | |
| 249 | """Abstract base class partially implementing the ResourceLoader and |
| 250 | ExecutionLoader ABCs.""" |
| 251 | |
| 252 | _register(FileLoader, machinery.SourceFileLoader, |
Marc-Andre Lemburg | 4fe29c9 | 2012-04-25 02:31:37 +0200 | [diff] [blame] | 253 | machinery.SourcelessFileLoader) |
Brett Cannon | 938d44d | 2012-04-22 19:58:33 -0400 | [diff] [blame] | 254 | |
| 255 | |
Brett Cannon | 0cf9e6a | 2010-06-28 04:57:24 +0000 | [diff] [blame] | 256 | class SourceLoader(_bootstrap.SourceLoader, ResourceLoader, ExecutionLoader): |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 257 | |
Brett Cannon | f23e374 | 2010-06-27 23:57:46 +0000 | [diff] [blame] | 258 | """Abstract base class for loading source code (and optionally any |
| 259 | corresponding bytecode). |
Brett Cannon | 2a922ed | 2009-03-09 03:35:50 +0000 | [diff] [blame] | 260 | |
Brett Cannon | f23e374 | 2010-06-27 23:57:46 +0000 | [diff] [blame] | 261 | To support loading from source code, the abstractmethods inherited from |
| 262 | ResourceLoader and ExecutionLoader need to be implemented. To also support |
| 263 | loading from bytecode, the optional methods specified directly by this ABC |
| 264 | is required. |
| 265 | |
| 266 | Inherited abstractmethods not implemented in this ABC: |
| 267 | |
| 268 | * ResourceLoader.get_data |
| 269 | * ExecutionLoader.get_filename |
| 270 | |
| 271 | """ |
| 272 | |
Raymond Hettinger | cd92f37 | 2011-01-13 02:31:25 +0000 | [diff] [blame] | 273 | def path_mtime(self, path): |
Raymond Hettinger | d958ea7 | 2011-01-13 19:08:04 +0000 | [diff] [blame] | 274 | """Return the (int) modification time for the path (str).""" |
Antoine Pitrou | 5136ac0 | 2012-01-13 18:52:16 +0100 | [diff] [blame] | 275 | if self.path_stats.__func__ is SourceLoader.path_stats: |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 276 | raise IOError |
Antoine Pitrou | 5136ac0 | 2012-01-13 18:52:16 +0100 | [diff] [blame] | 277 | return int(self.path_stats(path)['mtime']) |
| 278 | |
| 279 | def path_stats(self, path): |
| 280 | """Return a metadata dict for the source pointed to by the path (str). |
| 281 | Possible keys: |
| 282 | - 'mtime' (mandatory) is the numeric timestamp of last source |
| 283 | code modification; |
| 284 | - 'size' (optional) is the size in bytes of the source code. |
| 285 | """ |
| 286 | if self.path_mtime.__func__ is SourceLoader.path_mtime: |
Brett Cannon | 100883f | 2013-04-09 16:59:39 -0400 | [diff] [blame] | 287 | raise IOError |
Antoine Pitrou | 5136ac0 | 2012-01-13 18:52:16 +0100 | [diff] [blame] | 288 | return {'mtime': self.path_mtime(path)} |
Brett Cannon | 8d18907 | 2010-08-22 20:38:47 +0000 | [diff] [blame] | 289 | |
Raymond Hettinger | cd92f37 | 2011-01-13 02:31:25 +0000 | [diff] [blame] | 290 | def set_data(self, path, data): |
Brett Cannon | 8d18907 | 2010-08-22 20:38:47 +0000 | [diff] [blame] | 291 | """Write the bytes to the path (if possible). |
| 292 | |
Raymond Hettinger | d958ea7 | 2011-01-13 19:08:04 +0000 | [diff] [blame] | 293 | Accepts a str path and data as bytes. |
| 294 | |
Brett Cannon | 8d18907 | 2010-08-22 20:38:47 +0000 | [diff] [blame] | 295 | Any needed intermediary directories are to be created. If for some |
| 296 | reason the file cannot be written because of permissions, fail |
| 297 | silently. |
Brett Cannon | 8d18907 | 2010-08-22 20:38:47 +0000 | [diff] [blame] | 298 | """ |
Brett Cannon | 8d18907 | 2010-08-22 20:38:47 +0000 | [diff] [blame] | 299 | |
Brett Cannon | 938d44d | 2012-04-22 19:58:33 -0400 | [diff] [blame] | 300 | _register(SourceLoader, machinery.SourceFileLoader) |