Skip to content

Commit 483fd73

Browse files
[sys] Add the 3.14 _jit 'module' (#15692)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 38ad421 commit 483fd73

6 files changed

Lines changed: 31 additions & 1 deletion

File tree

stdlib/@tests/stubtest_allowlists/py314.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ importlib.metadata.DeprecatedNonAbstract.__new__
132132
importlib.resources._common.files
133133

134134
sys._monitoring # Doesn't really exist. See comments in the stub.
135+
sys.__jit # Similar to sys._monitoring
135136
sys.last_exc # not always defined
136137

137138
# These only exist to give a better error message if you try to subclass an instance
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import sys
2+
from typing_extensions import assert_type
3+
4+
if sys.version_info >= (3, 14):
5+
assert_type(sys._jit.is_available(), bool)
6+
assert_type(sys._jit.is_enabled(), bool)
7+
assert_type(sys._jit.is_active(), bool)
8+
9+
def sys_is_not_a_package() -> None:
10+
# This has to be put into a function, because otherwise the presence
11+
# of this import statement causes errors on the above usages of `sys._jit`.
12+
import sys._jit # type: ignore

stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ sunau: 3.0-3.12
295295
symbol: 3.0-3.9
296296
symtable: 3.0-
297297
sys: 3.0-
298+
sys.__jit: 3.14- # Similar to sys._monitoring
298299
sys._monitoring: 3.12- # Doesn't actually exist. See comments in the stub.
299300
sysconfig: 3.0-
300301
syslog: 3.0-

stdlib/sys/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,7 @@ if sys.version_info >= (3, 14):
518518
def is_remote_debug_enabled() -> bool: ...
519519
def remote_exec(pid: int, script: StrOrBytesPath) -> None: ...
520520
def _is_immortal(op: object, /) -> bool: ...
521+
522+
from . import __jit
523+
524+
_jit = __jit

stdlib/sys/__jit.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This py314+ module provides annotations for `sys._jit`.
2+
# It's named `sys.__jit` in typeshed,
3+
# because trying to import `sys._jit` will fail at runtime!
4+
# At runtime, `sys._jit` has the unusual status
5+
# of being a `types.ModuleType` instance that cannot be directly imported,
6+
# (same as sys.monitoring)
7+
# and exists in the `sys`-module namespace despite `sys` not being a package.
8+
9+
def is_available() -> bool: ...
10+
def is_enabled() -> bool: ...
11+
def is_active() -> bool: ...

stdlib/sys/_monitoring.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# This py312+ module provides annotations for `sys.monitoring`.
22
# It's named `sys._monitoring` in typeshed,
33
# because trying to import `sys.monitoring` will fail at runtime!
4-
# At runtime, `sys.monitoring` has the unique status
4+
# At runtime, `sys.monitoring` has the unusual status
55
# of being a `types.ModuleType` instance that cannot be directly imported,
6+
# (same as sys._jit)
67
# and exists in the `sys`-module namespace despite `sys` not being a package.
78

89
import sys

0 commit comments

Comments
 (0)