Skip to content

Commit 451f92b

Browse files
Restrict importlib.abc.InspectLoader.source_to_code to only take bytes instead of Buffer as path.
1 parent ca91efd commit 451f92b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

stdlib/importlib/abc.pyi

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ class InspectLoader(Loader):
5151
@abstractmethod
5252
def get_source(self, fullname: str) -> str | None: ...
5353
def exec_module(self, module: types.ModuleType) -> None: ...
54-
@staticmethod
55-
def source_to_code(
56-
data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: ReadableBuffer | StrPath = "<string>"
57-
) -> types.CodeType: ...
54+
if sys.version_info >= (3, 12):
55+
@staticmethod
56+
def source_to_code(
57+
data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: bytes | StrPath = "<string>"
58+
) -> types.CodeType: ...
59+
else:
60+
@staticmethod
61+
def source_to_code(
62+
data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: ReadableBuffer | StrPath = "<string>"
63+
) -> types.CodeType: ...
5864

5965
class ExecutionLoader(InspectLoader):
6066
@abstractmethod

0 commit comments

Comments
 (0)