Issue #14605: Rename _SourcelessFileLoader to SourcelessFileLoader.

This time also recreating the Python/importlib.h file to make
make happy. See the ticket for details.
This commit is contained in:
Marc-Andre Lemburg 2012-04-25 02:31:37 +02:00
parent ac8805a01a
commit 4fe29c9657
11 changed files with 1445 additions and 1448 deletions

View File

@ -606,18 +606,15 @@ find and load modules.
Load the specified module if it is the same as :attr:`name`. Load the specified module if it is the same as :attr:`name`.
.. class:: _SourcelessFileLoader(fullname, path) .. class:: SourcelessFileLoader(fullname, path)
A concrete implementation of :class:`importlib.abc.FileLoader` which can A concrete implementation of :class:`importlib.abc.FileLoader` which can
import bytecode files (i.e. no source code files exist). import bytecode files (i.e. no source code files exist).
It is **strongly** suggested you do not rely on this loader (hence the Please note that direct use of bytecode files (and thus not source code
leading underscore of the class). Direct use of bytecode files (and thus not files) inhibits your modules from being usable by all Python
source code files) inhibits your modules from being usable by all Python implementations or new versions of Python which change the bytecode
implementations. It also runs the risk of your bytecode files not being format.
usable by new versions of Python which change the bytecode format. This
class is only documented as it is directly used by import and thus can
potentially have instances show up as a module's ``__loader__`` attribute.
.. versionadded:: 3.3 .. versionadded:: 3.3

View File

@ -94,7 +94,7 @@ def load_source(name, pathname, file=None):
class _LoadCompiledCompatibility(_HackedGetData, class _LoadCompiledCompatibility(_HackedGetData,
_bootstrap._SourcelessFileLoader): _bootstrap.SourcelessFileLoader):
"""Compatibility support for implementing load_compiled().""" """Compatibility support for implementing load_compiled()."""

View File

@ -671,7 +671,7 @@ class SourceFileLoader(FileLoader, SourceLoader):
pass pass
class _SourcelessFileLoader(FileLoader, _LoaderBasics): class SourcelessFileLoader(FileLoader, _LoaderBasics):
"""Loader which handles sourceless file imports.""" """Loader which handles sourceless file imports."""
@ -1198,7 +1198,7 @@ def _setup(sys_module, _imp_module):
supported_loaders = [(ExtensionFileLoader, _suffix_list(3), False), supported_loaders = [(ExtensionFileLoader, _suffix_list(3), False),
(SourceFileLoader, _suffix_list(1), True), (SourceFileLoader, _suffix_list(1), True),
(_SourcelessFileLoader, _suffix_list(2), True)] (SourcelessFileLoader, _suffix_list(2), True)]
setattr(self_module, '_DEFAULT_PATH_HOOK', setattr(self_module, '_DEFAULT_PATH_HOOK',
FileFinder.path_hook(*supported_loaders)) FileFinder.path_hook(*supported_loaders))

View File

@ -119,7 +119,7 @@ class FileLoader(_bootstrap.FileLoader, ResourceLoader, ExecutionLoader):
ExecutionLoader ABCs.""" ExecutionLoader ABCs."""
_register(FileLoader, machinery.SourceFileLoader, _register(FileLoader, machinery.SourceFileLoader,
machinery._SourcelessFileLoader) machinery.SourcelessFileLoader)
class SourceLoader(_bootstrap.SourceLoader, ResourceLoader, ExecutionLoader): class SourceLoader(_bootstrap.SourceLoader, ResourceLoader, ExecutionLoader):

View File

@ -5,5 +5,5 @@ from ._bootstrap import FrozenImporter
from ._bootstrap import PathFinder from ._bootstrap import PathFinder
from ._bootstrap import FileFinder from ._bootstrap import FileFinder
from ._bootstrap import SourceFileLoader from ._bootstrap import SourceFileLoader
from ._bootstrap import _SourcelessFileLoader from ._bootstrap import SourcelessFileLoader
from ._bootstrap import ExtensionFileLoader from ._bootstrap import ExtensionFileLoader

View File

@ -24,7 +24,7 @@ class CaseSensitivityTest(unittest.TestCase):
(_bootstrap.SourceFileLoader, (_bootstrap.SourceFileLoader,
_bootstrap._suffix_list(imp.PY_SOURCE), _bootstrap._suffix_list(imp.PY_SOURCE),
True), True),
(_bootstrap._SourcelessFileLoader, (_bootstrap.SourcelessFileLoader,
_bootstrap._suffix_list(imp.PY_COMPILED), _bootstrap._suffix_list(imp.PY_COMPILED),
True)) True))
return finder.find_module(self.name) return finder.find_module(self.name)

View File

@ -379,7 +379,7 @@ class SourceLoaderBadBytecodeTest(BadBytecodeTest):
class SourcelessLoaderBadBytecodeTest(BadBytecodeTest): class SourcelessLoaderBadBytecodeTest(BadBytecodeTest):
loader = _bootstrap._SourcelessFileLoader loader = _bootstrap.SourcelessFileLoader
def test_empty_file(self): def test_empty_file(self):
def test(name, mapping, bytecode_path): def test(name, mapping, bytecode_path):

View File

@ -38,7 +38,7 @@ class FinderTests(abc.FinderTests):
def import_(self, root, module): def import_(self, root, module):
loader_details = [(_bootstrap.SourceFileLoader, loader_details = [(_bootstrap.SourceFileLoader,
_bootstrap._suffix_list(imp.PY_SOURCE), True), _bootstrap._suffix_list(imp.PY_SOURCE), True),
(_bootstrap._SourcelessFileLoader, (_bootstrap.SourcelessFileLoader,
_bootstrap._suffix_list(imp.PY_COMPILED), True)] _bootstrap._suffix_list(imp.PY_COMPILED), True)]
finder = _bootstrap.FileFinder(root, *loader_details) finder = _bootstrap.FileFinder(root, *loader_details)
return finder.find_module(module) return finder.find_module(module)

View File

@ -62,7 +62,7 @@ class ExecutionLoader(InheritanceTests, unittest.TestCase):
class FileLoader(InheritanceTests, unittest.TestCase): class FileLoader(InheritanceTests, unittest.TestCase):
superclasses = [abc.ResourceLoader, abc.ExecutionLoader] superclasses = [abc.ResourceLoader, abc.ExecutionLoader]
subclasses = [machinery.SourceFileLoader, machinery._SourcelessFileLoader] subclasses = [machinery.SourceFileLoader, machinery.SourcelessFileLoader]
class SourceLoader(InheritanceTests, unittest.TestCase): class SourceLoader(InheritanceTests, unittest.TestCase):

View File

@ -84,7 +84,7 @@ Library
which send EOF without trailing \r\n. which send EOF without trailing \r\n.
- Issue #14605: Add importlib.abc.FileLoader, importlib.machinery.(FileFinder, - Issue #14605: Add importlib.abc.FileLoader, importlib.machinery.(FileFinder,
SourceFileLoader, _SourcelessFileLoader, ExtensionFileLoader). SourceFileLoader, SourcelessFileLoader, ExtensionFileLoader).
- Issue #13959: imp.cache_from_source()/source_from_cache() now follow - Issue #13959: imp.cache_from_source()/source_from_cache() now follow
os.path.join()/split() semantics for path manipulation instead of its prior, os.path.join()/split() semantics for path manipulation instead of its prior,

File diff suppressed because it is too large Load Diff