Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4afab6b3
Commit
4afab6b3
authored
Feb 21, 2009
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate out finder for source and source/bytecode.
parent
2dee597e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
10 deletions
+21
-10
Lib/importlib/NOTES
Lib/importlib/NOTES
+9
-6
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+10
-2
Lib/importlib/test/source/test_case_sensitivity.py
Lib/importlib/test/source/test_case_sensitivity.py
+1
-1
Lib/importlib/test/source/test_finder.py
Lib/importlib/test/source/test_finder.py
+1
-1
No files found.
Lib/importlib/NOTES
View file @
4afab6b3
...
...
@@ -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
...
...
Lib/importlib/_bootstrap.py
View file @
4afab6b3
...
...
@@ -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
,
Py
Pyc
FileFinder
)
class
_DefaultPathFinder
(
PathFinder
):
...
...
Lib/importlib/test/source/test_case_sensitivity.py
View file @
4afab6b3
...
...
@@ -19,7 +19,7 @@ class CaseSensitivityTest(unittest.TestCase):
assert
name
!=
name
.
lower
()
def
find
(
self
,
path
):
finder
=
importlib
.
PyFileFinder
(
path
)
finder
=
importlib
.
Py
Pyc
FileFinder
(
path
)
return
finder
.
find_module
(
self
.
name
)
def
sensitivity_test
(
self
):
...
...
Lib/importlib/test/source/test_finder.py
View file @
4afab6b3
...
...
@@ -32,7 +32,7 @@ class FinderTests(abc.FinderTests):
"""
def
import_
(
self
,
root
,
module
):
finder
=
importlib
.
PyFileFinder
(
root
)
finder
=
importlib
.
Py
Pyc
FileFinder
(
root
)
return
finder
.
find_module
(
module
)
def
run_test
(
self
,
test
,
create
=
None
,
*
,
compile_
=
None
,
unlink
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment