mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Separate out finder for source and source/bytecode.
This commit is contained in:
parent
2dee597e05
commit
4afab6b30b
4 changed files with 21 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue