Commit 4afab6b3 authored by Brett Cannon's avatar Brett Cannon

Separate out finder for source and source/bytecode.

parent 2dee597e
...@@ -5,19 +5,22 @@ to do ...@@ -5,19 +5,22 @@ to do
subclass of source support (makes it nicer for VMs that don't use CPython subclass of source support (makes it nicer for VMs that don't use CPython
bytecode). bytecode).
+ ExtensionFileFinder + PyLoader (for ABC)
+ PyFileFinder
+ PyPycFileFinder
+ PyFileLoader
- get_code for source only - get_code for source only
+ PyFileLoader(PyLoader)
- get_data - get_data
- source_mtime - source_mtime
- source_path - source_path
+ PyPycFileLoader(PyFileLoader) +PyPycLoader (PyLoader, for ABC)
- get_code for source and bytecode
+ PyPycFileLoader(PyPycLoader, PyFileLoader)
- get_code
- bytecode_path - bytecode_path
- write_bytecode - write_bytecode
......
...@@ -592,10 +592,18 @@ class PyFileFinder(FileFinder): ...@@ -592,10 +592,18 @@ class PyFileFinder(FileFinder):
# Make sure that Python source files are listed first! Needed for an # Make sure that Python source files are listed first! Needed for an
# optimization by the loader. # optimization by the loader.
self._suffixes = suffix_list(imp.PY_SOURCE) self._suffixes = suffix_list(imp.PY_SOURCE)
self._suffixes += suffix_list(imp.PY_COMPILED)
super().__init__(path_entry) 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: class PathFinder:
"""Meta path finder for sys.(path|path_hooks|path_importer_cache).""" """Meta path finder for sys.(path|path_hooks|path_importer_cache)."""
...@@ -659,7 +667,7 @@ class PathFinder: ...@@ -659,7 +667,7 @@ class PathFinder:
return None return None
_DEFAULT_PATH_HOOK = chained_path_hook(ExtensionFileFinder, PyFileFinder) _DEFAULT_PATH_HOOK = chained_path_hook(ExtensionFileFinder, PyPycFileFinder)
class _DefaultPathFinder(PathFinder): class _DefaultPathFinder(PathFinder):
......
...@@ -19,7 +19,7 @@ class CaseSensitivityTest(unittest.TestCase): ...@@ -19,7 +19,7 @@ class CaseSensitivityTest(unittest.TestCase):
assert name != name.lower() assert name != name.lower()
def find(self, path): def find(self, path):
finder = importlib.PyFileFinder(path) finder = importlib.PyPycFileFinder(path)
return finder.find_module(self.name) return finder.find_module(self.name)
def sensitivity_test(self): def sensitivity_test(self):
......
...@@ -32,7 +32,7 @@ class FinderTests(abc.FinderTests): ...@@ -32,7 +32,7 @@ class FinderTests(abc.FinderTests):
""" """
def import_(self, root, module): def import_(self, root, module):
finder = importlib.PyFileFinder(root) finder = importlib.PyPycFileFinder(root)
return finder.find_module(module) return finder.find_module(module)
def run_test(self, test, create=None, *, compile_=None, unlink=None): def run_test(self, test, create=None, *, compile_=None, unlink=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment