Skip to content

Commit 4faad91

Browse files
authored
Add _interpreters module for 3.13 (#12230)
1 parent 2ea26f7 commit 4faad91

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ _dummy_threading: 3.0-3.8
3535
_heapq: 3.0-
3636
_imp: 3.0-
3737
_interpchannels: 3.13-
38+
_interpreters: 3.13-
3839
_json: 3.0-
3940
_locale: 3.0-
4041
_lsprof: 3.0-

stdlib/_interpreters.pyi

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import types
2+
from collections.abc import Callable, Mapping
3+
from typing import Final, Literal, SupportsIndex
4+
from typing_extensions import TypeAlias
5+
6+
_Configs: TypeAlias = Literal["default", "isolated", "legacy", "empty", ""]
7+
8+
class InterpreterError(Exception): ...
9+
class InterpreterNotFoundError(InterpreterError): ...
10+
class NotShareableError(Exception): ...
11+
12+
class CrossInterpreterBufferView:
13+
def __buffer__(self, flags: int, /) -> memoryview: ...
14+
15+
def new_config(name: _Configs = "isolated", /, **overides: object) -> types.SimpleNamespace: ...
16+
def create(config: types.SimpleNamespace | _Configs | None = "isolated", *, reqrefs: bool = False) -> int: ...
17+
def destroy(id: SupportsIndex, *, restrict: bool = False) -> None: ...
18+
def list_all(*, require_ready: bool) -> list[tuple[int, int]]: ...
19+
def get_current() -> tuple[int, int]: ...
20+
def get_main() -> tuple[int, int]: ...
21+
def is_running(id: SupportsIndex, *, restrict: bool = False) -> bool: ...
22+
def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleNamespace: ...
23+
def whence(id: SupportsIndex) -> int: ...
24+
def exec(id: SupportsIndex, code: str, shared: bool | None = None, *, restrict: bool = False) -> None: ...
25+
def call(
26+
id: SupportsIndex,
27+
callable: Callable[..., object],
28+
args: tuple[object, ...] | None = None,
29+
kwargs: dict[str, object] | None = None,
30+
*,
31+
restrict: bool = False,
32+
) -> object: ...
33+
def run_string(
34+
id: SupportsIndex, script: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
35+
) -> None: ...
36+
def run_func(
37+
id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
38+
) -> None: ...
39+
def set___main___attrs(id: SupportsIndex, updates: Mapping[str, object], *, restrict: bool = False) -> None: ...
40+
def incref(id: SupportsIndex, *, implieslink: bool = False, restrict: bool = False) -> None: ...
41+
def decref(id: SupportsIndex, *, restrict: bool = False) -> None: ...
42+
def is_shareable(obj: object) -> bool: ...
43+
def capture_exception(exc: BaseException | None = None) -> types.SimpleNamespace: ...
44+
45+
WHENCE_UNKNOWN: Final = 0
46+
WHENCE_RUNTIME: Final = 1
47+
WHENCE_LEGACY_CAPI: Final = 2
48+
WHENCE_CAPI: Final = 3
49+
WHENCE_XI: Final = 4
50+
WHENCE_STDLIB: Final = 5

0 commit comments

Comments
 (0)