summaryrefslogtreecommitdiff
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-02-21 03:31:35 +0000
committerBrett Cannon <bcannon@gmail.com>2009-02-21 03:31:35 +0000
commit8d8fd08ea371998464f0b2b75c68fb0b84f8774d (patch)
tree3373860365f6d1641ea641d4e901c8377d24f78a /Lib/importlib
parent9b40dd2307c0bb9b249aabfeef242a7adecc3274 (diff)
downloadcpython-8d8fd08ea371998464f0b2b75c68fb0b84f8774d.tar.gz
Separate out finder for source and source/bytecode.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/NOTES15
-rw-r--r--Lib/importlib/_bootstrap.py12
-rw-r--r--Lib/importlib/test/source/test_case_sensitivity.py2
-rw-r--r--Lib/importlib/test/source/test_finder.py2
4 files changed, 21 insertions, 10 deletions
diff --git a/Lib/importlib/NOTES b/Lib/importlib/NOTES
index 92e2841d9c..1bbcb968e8 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 4db61da079..068ee1021c 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 df6d3bcff6..210e6208fb 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 0cfb14f3e1..1e4333cc48 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):