mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Tweak the source/bytecode loader from importlib to use more of the PEP 302
protocol API.
This commit is contained in:
parent
4afab6b30b
commit
0515619dbc
2 changed files with 3 additions and 3 deletions
|
@ -7,6 +7,7 @@ to do
|
||||||
|
|
||||||
+ PyLoader (for ABC)
|
+ PyLoader (for ABC)
|
||||||
|
|
||||||
|
- load_module for source only
|
||||||
- get_code for source only
|
- get_code for source only
|
||||||
|
|
||||||
+ PyFileLoader(PyLoader)
|
+ PyFileLoader(PyLoader)
|
||||||
|
@ -17,6 +18,7 @@ to do
|
||||||
|
|
||||||
+PyPycLoader (PyLoader, for ABC)
|
+PyPycLoader (PyLoader, for ABC)
|
||||||
|
|
||||||
|
- load_module for source and bytecode
|
||||||
- get_code for source and bytecode
|
- get_code for source and bytecode
|
||||||
|
|
||||||
+ PyPycFileLoader(PyPycLoader, PyFileLoader)
|
+ PyPycFileLoader(PyPycLoader, PyFileLoader)
|
||||||
|
|
|
@ -361,7 +361,6 @@ class _PyFileLoader:
|
||||||
# Not a property for easy overriding.
|
# Not a property for easy overriding.
|
||||||
return self._find_path(imp.PY_COMPILED)
|
return self._find_path(imp.PY_COMPILED)
|
||||||
|
|
||||||
@check_name
|
|
||||||
@module_for_loader
|
@module_for_loader
|
||||||
def load_module(self, module):
|
def load_module(self, module):
|
||||||
"""Load a Python source or bytecode module."""
|
"""Load a Python source or bytecode module."""
|
||||||
|
@ -371,7 +370,7 @@ class _PyFileLoader:
|
||||||
code_object = self.get_code(module.__name__)
|
code_object = self.get_code(module.__name__)
|
||||||
module.__file__ = source_path if source_path else bytecode_path
|
module.__file__ = source_path if source_path else bytecode_path
|
||||||
module.__loader__ = self
|
module.__loader__ = self
|
||||||
if self._is_pkg:
|
if self.is_package(name):
|
||||||
module.__path__ = [module.__file__.rsplit(path_sep, 1)[0]]
|
module.__path__ = [module.__file__.rsplit(path_sep, 1)[0]]
|
||||||
module.__package__ = module.__name__
|
module.__package__ = module.__name__
|
||||||
if not hasattr(module, '__path__'):
|
if not hasattr(module, '__path__'):
|
||||||
|
@ -429,7 +428,6 @@ class _PyFileLoader:
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@check_name
|
|
||||||
def get_code(self, name):
|
def get_code(self, name):
|
||||||
"""Return the code object for the module."""
|
"""Return the code object for the module."""
|
||||||
# XXX Care enough to make sure this call does not happen if the magic
|
# XXX Care enough to make sure this call does not happen if the magic
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue