GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — `importlib.abc.SourceLoader` issues `DeprecationWarning` because it inherits from `ResourceLoader` · Issue #137426 · python/cpython Closed Labels 3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:Problem
Exampleimport os import sys import warnings from collections.abc import Iterable from importlib.abc import SourceLoader from importlib.machinery import ModuleSpec from typing import Protocol class FinderLike(Protocol): def find_spec(self, fullname: str) -> ModuleSpec | None: ... class MyLoader(SourceLoader): """Bare-bone `SourceLoader` subclass, only providing implementations for the abstract methods.""" @staticmethod def get_data(path: os.PathLike | str) -> bytes: with open(path, mode='rb') as fobj: return fobj.read() @staticmethod def get_filename(fullname: str, finders: Iterable[FinderLike] | None = None) -> str: if finders is None: finders = ( f for f in sys.meta_path if callable(getattr(f, 'find_spec', None)) if not isinstance(f, MyLoader) # Avoid circular dependence ) for finder in finders: try: spec = finder.find_spec(fullname) if spec is None: raise TypeError except (TypeError, ImportError): continue if spec.origin is not None and os.path.isfile(spec.origin): return str(spec.origin) raise ImportError(f'cannot find filename for `{fullname}`') with warnings.catch_warnings(): warnings.filterwarnings('error', category=DeprecationWarning) loader = MyLoader() # DeprecationWarning: importlib.abc.ResourceLoader is deprecated in favour of supporting resource loading through importlib.resources.abc.TraversableResources. Questions
Possibly related issuesCPython versions tested on:3.14 Operating systems tested on:macOS Linked PRsActivity
MetadataMetadataAssigneesLabels3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error Projects
MilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |