mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
gh-121604: Make sure all deprecated items in importlib raise DeprecationWarning (#128007)
Co-authored-by: rashansmith <smith.rashan@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Brett Cannon <brett@python.org>
This commit is contained in:
parent
b52de22ac3
commit
bd3baa8b1a
8 changed files with 96 additions and 5 deletions
|
|
@ -70,6 +70,15 @@ class ResourceLoader(Loader):
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
import warnings
|
||||
warnings.warn('importlib.abc.ResourceLoader is deprecated in '
|
||||
'favour of supporting resource loading through '
|
||||
'importlib.resources.abc.ResourceReader.',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
super().__init__()
|
||||
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_data(self, path):
|
||||
"""Abstract method which when implemented should return the bytes for
|
||||
|
|
@ -199,6 +208,10 @@ class SourceLoader(_bootstrap_external.SourceLoader, ResourceLoader, ExecutionLo
|
|||
|
||||
def path_mtime(self, path):
|
||||
"""Return the (int) modification time for the path (str)."""
|
||||
import warnings
|
||||
warnings.warn('SourceLoader.path_mtime is deprecated in favour of '
|
||||
'SourceLoader.path_stats().',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
if self.path_stats.__func__ is SourceLoader.path_stats:
|
||||
raise OSError
|
||||
return int(self.path_stats(path)['mtime'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue