|
12 | 12 | import _frozen_importlib_external |
13 | 13 | except ImportError: |
14 | 14 | _frozen_importlib_external = _bootstrap_external |
| 15 | +from ._abc import Loader |
15 | 16 | import abc |
16 | 17 | import warnings |
17 | 18 | from typing import Protocol, runtime_checkable |
@@ -134,53 +135,6 @@ def invalidate_caches(self): |
134 | 135 | _register(PathEntryFinder, machinery.FileFinder) |
135 | 136 |
|
136 | 137 |
|
137 | | -class Loader(metaclass=abc.ABCMeta): |
138 | | - |
139 | | - """Abstract base class for import loaders.""" |
140 | | - |
141 | | - def create_module(self, spec): |
142 | | - """Return a module to initialize and into which to load. |
143 | | -
|
144 | | - This method should raise ImportError if anything prevents it |
145 | | - from creating a new module. It may return None to indicate |
146 | | - that the spec should create the new module. |
147 | | - """ |
148 | | - # By default, defer to default semantics for the new module. |
149 | | - return None |
150 | | - |
151 | | - # We don't define exec_module() here since that would break |
152 | | - # hasattr checks we do to support backward compatibility. |
153 | | - |
154 | | - def load_module(self, fullname): |
155 | | - """Return the loaded module. |
156 | | -
|
157 | | - The module must be added to sys.modules and have import-related |
158 | | - attributes set properly. The fullname is a str. |
159 | | -
|
160 | | - ImportError is raised on failure. |
161 | | -
|
162 | | - This method is deprecated in favor of loader.exec_module(). If |
163 | | - exec_module() exists then it is used to provide a backwards-compatible |
164 | | - functionality for this method. |
165 | | -
|
166 | | - """ |
167 | | - if not hasattr(self, 'exec_module'): |
168 | | - raise ImportError |
169 | | - return _bootstrap._load_module_shim(self, fullname) |
170 | | - |
171 | | - def module_repr(self, module): |
172 | | - """Return a module's repr. |
173 | | -
|
174 | | - Used by the module type when the method does not raise |
175 | | - NotImplementedError. |
176 | | -
|
177 | | - This method is deprecated. |
178 | | -
|
179 | | - """ |
180 | | - # The exception will cause ModuleType.__repr__ to ignore this method. |
181 | | - raise NotImplementedError |
182 | | - |
183 | | - |
184 | 138 | class ResourceLoader(Loader): |
185 | 139 |
|
186 | 140 | """Abstract base class for loaders which can return data from their |
|
0 commit comments