mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Relocate source_mtime in importlib to PyPycLoader.
This commit is contained in:
parent
aa9d5de2ed
commit
94aaf9e4b8
1 changed files with 11 additions and 13 deletions
|
@ -320,7 +320,7 @@ class PyLoader:
|
||||||
"""Loader base class for Python source.
|
"""Loader base class for Python source.
|
||||||
|
|
||||||
Requires implementing the optional PEP 302 protocols as well as
|
Requires implementing the optional PEP 302 protocols as well as
|
||||||
source_mtime and source_path.
|
source_path.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ class PyPycLoader(PyLoader):
|
||||||
"""Loader base class for Python source and bytecode.
|
"""Loader base class for Python source and bytecode.
|
||||||
|
|
||||||
Requires implementing the methods needed for PyLoader as well as
|
Requires implementing the methods needed for PyLoader as well as
|
||||||
bytecode_path and write_bytecode.
|
source_mtime, bytecode_path, and write_bytecode.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -461,16 +461,6 @@ class PyFileLoader(PyLoader):
|
||||||
# Not a property so that it is easy to override.
|
# Not a property so that it is easy to override.
|
||||||
return self._find_path(imp.PY_SOURCE)
|
return self._find_path(imp.PY_SOURCE)
|
||||||
|
|
||||||
|
|
||||||
@check_name
|
|
||||||
def source_mtime(self, name):
|
|
||||||
"""Return the modification time of the source for the specified
|
|
||||||
module."""
|
|
||||||
source_path = self.source_path(name)
|
|
||||||
if not source_path:
|
|
||||||
return None
|
|
||||||
return int(_os.stat(source_path).st_mtime)
|
|
||||||
|
|
||||||
@check_name
|
@check_name
|
||||||
def get_source(self, fullname):
|
def get_source(self, fullname):
|
||||||
"""Return the source for the module as a string.
|
"""Return the source for the module as a string.
|
||||||
|
@ -505,11 +495,19 @@ class PyFileLoader(PyLoader):
|
||||||
return self._is_pkg
|
return self._is_pkg
|
||||||
|
|
||||||
|
|
||||||
# XXX Rename _PyFileLoader throughout
|
|
||||||
class PyPycFileLoader(PyPycLoader, PyFileLoader):
|
class PyPycFileLoader(PyPycLoader, PyFileLoader):
|
||||||
|
|
||||||
"""Load a module from a source or bytecode file."""
|
"""Load a module from a source or bytecode file."""
|
||||||
|
|
||||||
|
@check_name
|
||||||
|
def source_mtime(self, name):
|
||||||
|
"""Return the modification time of the source for the specified
|
||||||
|
module."""
|
||||||
|
source_path = self.source_path(name)
|
||||||
|
if not source_path:
|
||||||
|
return None
|
||||||
|
return int(_os.stat(source_path).st_mtime)
|
||||||
|
|
||||||
@check_name
|
@check_name
|
||||||
def bytecode_path(self, fullname):
|
def bytecode_path(self, fullname):
|
||||||
"""Return the path to a bytecode file, or None if one does not
|
"""Return the path to a bytecode file, or None if one does not
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue