diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-02-21 03:31:35 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-02-21 03:31:35 (GMT) |
commit | 4afab6b30b6262012946171fbcb69043c4b28efc (patch) | |
tree | 41b93494c5c79a251a12c30eabefa5cc8e0a33e8 /Lib | |
parent | 2dee597e0593a8f7b477f58afe5e46f94b994541 (diff) | |
download | cpython-4afab6b30b6262012946171fbcb69043c4b28efc.zip cpython-4afab6b30b6262012946171fbcb69043c4b28efc.tar.gz cpython-4afab6b30b6262012946171fbcb69043c4b28efc.tar.bz2 |
Separate out finder for source and source/bytecode.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/importlib/NOTES | 15 | ||||
-rw-r--r-- | Lib/importlib/_bootstrap.py | 12 | ||||
-rw-r--r-- | Lib/importlib/test/source/test_case_sensitivity.py | 2 | ||||
-rw-r--r-- | Lib/importlib/test/source/test_finder.py | 2 |
4 files changed, 21 insertions, 10 deletions
diff --git a/Lib/importlib/NOTES b/Lib/importlib/NOTES index 92e2841..1bbcb96 100644 --- a/Lib/importlib/NOTES +++ b/Lib/importlib/NOTES @@ -5,19 +5,22 @@ to do subclass of source support (makes it nicer for VMs that don't use CPython bytecode). - + ExtensionFileFinder - + PyFileFinder - + PyPycFileFinder - + PyFileLoader + + PyLoader (for ABC) - get_code for source only + + + PyFileLoader(PyLoader) + - get_data - source_mtime - source_path - + PyPycFileLoader(PyFileLoader) + +PyPycLoader (PyLoader, for ABC) + + - get_code for source and bytecode + + + PyPycFileLoader(PyPycLoader, PyFileLoader) - - get_code - bytecode_path - write_bytecode diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 4db61da..068ee10 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -592,10 +592,18 @@ class PyFileFinder(FileFinder): # Make sure that Python source files are listed first! Needed for an # optimization by the loader. self._suffixes = suffix_list(imp.PY_SOURCE) - self._suffixes += suffix_list(imp.PY_COMPILED) super().__init__(path_entry) +class PyPycFileFinder(PyFileFinder): + + """Finder for source and bytecode files.""" + + def __init__(self, path_entry): + super().__init__(path_entry) + self._suffixes += suffix_list(imp.PY_COMPILED) + + class PathFinder: """Meta path finder for sys.(path|path_hooks|path_importer_cache).""" @@ -659,7 +667,7 @@ class PathFinder: return None -_DEFAULT_PATH_HOOK = chained_path_hook(ExtensionFileFinder, PyFileFinder) +_DEFAULT_PATH_HOOK = chained_path_hook(ExtensionFileFinder, PyPycFileFinder) class _DefaultPathFinder(PathFinder): diff --git a/Lib/importlib/test/source/test_case_sensitivity.py b/Lib/importlib/test/source/test_case_sensitivity.py index df6d3bc..210e620 100644 --- a/Lib/importlib/test/source/test_case_sensitivity.py +++ b/Lib/importlib/test/source/test_case_sensitivity.py @@ -19,7 +19,7 @@ class CaseSensitivityTest(unittest.TestCase): assert name != name.lower() def find(self, path): - finder = importlib.PyFileFinder(path) + finder = importlib.PyPycFileFinder(path) return finder.find_module(self.name) def sensitivity_test(self): diff --git a/Lib/importlib/test/source/test_finder.py b/Lib/importlib/test/source/test_finder.py index 0cfb14f..1e4333c 100644 --- a/Lib/importlib/test/source/test_finder.py +++ b/Lib/importlib/test/source/test_finder.py @@ -32,7 +32,7 @@ class FinderTests(abc.FinderTests): """ def import_(self, root, module): - finder = importlib.PyFileFinder(root) + finder = importlib.PyPycFileFinder(root) return finder.find_module(module) def run_test(self, test, create=None, *, compile_=None, unlink=None): |