(original) (raw)

changeset: 76547:e30196bfc11d user: Marc-Andre Lemburg mal@egenix.com date: Wed Apr 25 02:11:07 2012 +0200 files: Doc/library/importlib.rst Lib/imp.py Lib/importlib/_bootstrap.py Lib/importlib/abc.py Lib/importlib/machinery.py Lib/importlib/test/source/test_case_sensitivity.py Lib/importlib/test/source/test_file_loader.py Lib/importlib/test/source/test_finder.py Lib/importlib/test/test_abc.py Misc/NEWS description: Issue #14605: Revert renaming of _SourcelessFileLoader, since it caused the buildbots to fail. diff -r 8aa4737d67d2 -r e30196bfc11d Doc/library/importlib.rst --- a/Doc/library/importlib.rst Wed Apr 25 01:36:48 2012 +0200 +++ b/Doc/library/importlib.rst Wed Apr 25 02:11:07 2012 +0200 @@ -606,15 +606,18 @@ 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 import bytecode files (i.e. no source code files exist). - Please note that direct use of bytecode files (and thus not source code - files) inhibits your modules from being usable by all Python - implementations or new versions of Python which change the bytecode - format. + It is **strongly** suggested you do not rely on this loader (hence the + leading underscore of the class). Direct use of bytecode files (and thus not + source code files) inhibits your modules from being usable by all Python + implementations. It also runs the risk of your bytecode files not being + 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 diff -r 8aa4737d67d2 -r e30196bfc11d Lib/imp.py --- a/Lib/imp.py Wed Apr 25 01:36:48 2012 +0200 +++ b/Lib/imp.py Wed Apr 25 02:11:07 2012 +0200 @@ -94,7 +94,7 @@ class _LoadCompiledCompatibility(_HackedGetData, - _bootstrap.SourcelessFileLoader): + _bootstrap._SourcelessFileLoader): """Compatibility support for implementing load_compiled().""" diff -r 8aa4737d67d2 -r e30196bfc11d Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py Wed Apr 25 01:36:48 2012 +0200 +++ b/Lib/importlib/_bootstrap.py Wed Apr 25 02:11:07 2012 +0200 @@ -671,7 +671,7 @@ pass -class SourcelessFileLoader(FileLoader, _LoaderBasics): +class _SourcelessFileLoader(FileLoader, _LoaderBasics): """Loader which handles sourceless file imports.""" @@ -1198,7 +1198,7 @@ supported_loaders = [(ExtensionFileLoader, _suffix_list(3), False), (SourceFileLoader, _suffix_list(1), True), - (SourcelessFileLoader, _suffix_list(2), True)] + (_SourcelessFileLoader, _suffix_list(2), True)] setattr(self_module, '_DEFAULT_PATH_HOOK', FileFinder.path_hook(*supported_loaders)) diff -r 8aa4737d67d2 -r e30196bfc11d Lib/importlib/abc.py --- a/Lib/importlib/abc.py Wed Apr 25 01:36:48 2012 +0200 +++ b/Lib/importlib/abc.py Wed Apr 25 02:11:07 2012 +0200 @@ -119,7 +119,7 @@ ExecutionLoader ABCs.""" _register(FileLoader, machinery.SourceFileLoader, - machinery.SourcelessFileLoader) + machinery._SourcelessFileLoader) class SourceLoader(_bootstrap.SourceLoader, ResourceLoader, ExecutionLoader): diff -r 8aa4737d67d2 -r e30196bfc11d Lib/importlib/machinery.py --- a/Lib/importlib/machinery.py Wed Apr 25 01:36:48 2012 +0200 +++ b/Lib/importlib/machinery.py Wed Apr 25 02:11:07 2012 +0200 @@ -5,5 +5,5 @@ from ._bootstrap import PathFinder from ._bootstrap import FileFinder from ._bootstrap import SourceFileLoader -from ._bootstrap import SourcelessFileLoader +from ._bootstrap import _SourcelessFileLoader from ._bootstrap import ExtensionFileLoader diff -r 8aa4737d67d2 -r e30196bfc11d Lib/importlib/test/source/test_case_sensitivity.py --- a/Lib/importlib/test/source/test_case_sensitivity.py Wed Apr 25 01:36:48 2012 +0200 +++ b/Lib/importlib/test/source/test_case_sensitivity.py Wed Apr 25 02:11:07 2012 +0200 @@ -24,7 +24,7 @@ (_bootstrap.SourceFileLoader, _bootstrap._suffix_list(imp.PY_SOURCE), True), - (_bootstrap.SourcelessFileLoader, + (_bootstrap._SourcelessFileLoader, _bootstrap._suffix_list(imp.PY_COMPILED), True)) return finder.find_module(self.name) diff -r 8aa4737d67d2 -r e30196bfc11d Lib/importlib/test/source/test_file_loader.py --- a/Lib/importlib/test/source/test_file_loader.py Wed Apr 25 01:36:48 2012 +0200 +++ b/Lib/importlib/test/source/test_file_loader.py Wed Apr 25 02:11:07 2012 +0200 @@ -379,7 +379,7 @@ class SourcelessLoaderBadBytecodeTest(BadBytecodeTest): - loader = _bootstrap.SourcelessFileLoader + loader = _bootstrap._SourcelessFileLoader def test_empty_file(self): def test(name, mapping, bytecode_path): diff -r 8aa4737d67d2 -r e30196bfc11d Lib/importlib/test/source/test_finder.py --- a/Lib/importlib/test/source/test_finder.py Wed Apr 25 01:36:48 2012 +0200 +++ b/Lib/importlib/test/source/test_finder.py Wed Apr 25 02:11:07 2012 +0200 @@ -38,7 +38,7 @@ def import_(self, root, module): loader_details = [(_bootstrap.SourceFileLoader, _bootstrap._suffix_list(imp.PY_SOURCE), True), - (_bootstrap.SourcelessFileLoader, + (_bootstrap._SourcelessFileLoader, _bootstrap._suffix_list(imp.PY_COMPILED), True)] finder = _bootstrap.FileFinder(root, *loader_details) return finder.find_module(module) diff -r 8aa4737d67d2 -r e30196bfc11d Lib/importlib/test/test_abc.py --- a/Lib/importlib/test/test_abc.py Wed Apr 25 01:36:48 2012 +0200 +++ b/Lib/importlib/test/test_abc.py Wed Apr 25 02:11:07 2012 +0200 @@ -62,7 +62,7 @@ class FileLoader(InheritanceTests, unittest.TestCase): superclasses = [abc.ResourceLoader, abc.ExecutionLoader] - subclasses = [machinery.SourceFileLoader, machinery.SourcelessFileLoader] + subclasses = [machinery.SourceFileLoader, machinery._SourcelessFileLoader] class SourceLoader(InheritanceTests, unittest.TestCase): diff -r 8aa4737d67d2 -r e30196bfc11d Misc/NEWS --- a/Misc/NEWS Wed Apr 25 01:36:48 2012 +0200 +++ b/Misc/NEWS Wed Apr 25 02:11:07 2012 +0200 @@ -84,7 +84,7 @@ which send EOF without trailing \r\n. - 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 os.path.join()/split() semantics for path manipulation instead of its prior, /mal@egenix.com