Skip to content

Commit a32af68

Browse files
authored
threading updates for 3.14 (#14032)
1 parent e224b28 commit a32af68

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

stdlib/@tests/stubtest_allowlists/py314.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ string.templatelib
141141
sys.is_remote_debug_enabled
142142
sys.remote_exec
143143
tarfile.TarFile.zstopen
144-
threading.Thread.__init__
145-
threading._RLock.locked
146144
tkinter.Event.__class_getitem__
147145
turtle.__all__
148146
turtle.RawTurtle.fill

stdlib/threading.pyi

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import sys
33
from _thread import _excepthook, _ExceptHookArgs, get_native_id as get_native_id
44
from _typeshed import ProfileFunction, TraceFunction
55
from collections.abc import Callable, Iterable, Mapping
6+
from contextvars import ContextVar
67
from types import TracebackType
78
from typing import Any, TypeVar, final
89
from typing_extensions import deprecated
@@ -76,16 +77,30 @@ class Thread:
7677
@property
7778
def ident(self) -> int | None: ...
7879
daemon: bool
79-
def __init__(
80-
self,
81-
group: None = None,
82-
target: Callable[..., object] | None = None,
83-
name: str | None = None,
84-
args: Iterable[Any] = (),
85-
kwargs: Mapping[str, Any] | None = None,
86-
*,
87-
daemon: bool | None = None,
88-
) -> None: ...
80+
if sys.version_info >= (3, 14):
81+
def __init__(
82+
self,
83+
group: None = None,
84+
target: Callable[..., object] | None = None,
85+
name: str | None = None,
86+
args: Iterable[Any] = (),
87+
kwargs: Mapping[str, Any] | None = None,
88+
*,
89+
daemon: bool | None = None,
90+
context: ContextVar[Any] | None = None,
91+
) -> None: ...
92+
else:
93+
def __init__(
94+
self,
95+
group: None = None,
96+
target: Callable[..., object] | None = None,
97+
name: str | None = None,
98+
args: Iterable[Any] = (),
99+
kwargs: Mapping[str, Any] | None = None,
100+
*,
101+
daemon: bool | None = None,
102+
) -> None: ...
103+
89104
def start(self) -> None: ...
90105
def run(self) -> None: ...
91106
def join(self, timeout: float | None = None) -> None: ...
@@ -116,6 +131,9 @@ class _RLock:
116131
__enter__ = acquire
117132
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
118133

134+
if sys.version_info >= (3, 14):
135+
def locked(self) -> bool: ...
136+
119137
RLock = _thread.RLock # Actually a function at runtime.
120138

121139
class Condition:

0 commit comments

Comments
 (0)