From 2576a8771cba953f02fe479c432b8eabce63efce Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Sat, 8 Aug 2026 18:04:15 +0200 Subject: [PATCH] [importlib.abc] Add fullname parameter to source_to_code for Python 3.15 --- stdlib/@tests/stubtest_allowlists/py315.txt | 1 - stdlib/importlib/abc.pyi | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py315.txt b/stdlib/@tests/stubtest_allowlists/py315.txt index fcd88edaf791..cd4466f40ad7 100644 --- a/stdlib/@tests/stubtest_allowlists/py315.txt +++ b/stdlib/@tests/stubtest_allowlists/py315.txt @@ -22,7 +22,6 @@ dataclasses._MISSING_TYPE dataclasses.field importlib._abc.Loader.load_module importlib._bootstrap_external.NamespacePath -importlib.abc.InspectLoader.source_to_code importlib.abc.MetaPathFinder.discover importlib.abc.PathEntryFinder.discover importlib.resources._common.package_to_anchor diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 945b8d2080d1..489710887248 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -41,10 +41,19 @@ class InspectLoader(Loader): @abstractmethod def get_source(self, fullname: str) -> str | None: ... def exec_module(self, module: types.ModuleType) -> None: ... - @staticmethod - def source_to_code( - data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: bytes | StrPath = "" - ) -> types.CodeType: ... + + if sys.version_info >= (3, 15): + @staticmethod + def source_to_code( + data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, + path: bytes | StrPath = "", + fullname: str | None = None, + ) -> types.CodeType: ... + else: + @staticmethod + def source_to_code( + data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: bytes | StrPath = "" + ) -> types.CodeType: ... class ExecutionLoader(InspectLoader): @abstractmethod