Skip to content

Commit 27ec4c8

Browse files
Add more Python 3.15 stdlib updates (#15752)
1 parent 270ac3e commit 27ec4c8

12 files changed

Lines changed: 169 additions & 77 deletions

File tree

stdlib/@tests/stubtest_allowlists/py315.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ concurrent.interpreters._crossinterp.classonly.__isabstractmethod__
6969
concurrent.interpreters._crossinterp.classonly.__set_name__
7070
concurrent.interpreters._crossinterp.classonly.__wrapped__
7171
copy.deepcopy
72-
ctypes.SetPointerType
7372
dataclasses._MISSING_TYPE
7473
dataclasses.MISSING
7574
dataclasses.field
@@ -87,9 +86,6 @@ genericpath.getmtime
8786
genericpath.getsize
8887
genericpath.samefile
8988
genericpath.samestat
90-
glob.glob0
91-
glob.glob1
92-
gzip.compress
9389
http.HTTPMethod.description
9490
http.client.HTTPConnection.__init__
9591
http.client.HTTPSConnection.__init__
@@ -121,10 +117,6 @@ io.Writer.write
121117
mailbox.Mailbox.__enter__
122118
mailbox.Mailbox.__exit__
123119
mailbox._ProxyFile.__class_getitem__
124-
marshal.dump
125-
marshal.dumps
126-
multiprocessing.context.BaseContext.set_forkserver_preload
127-
multiprocessing.forkserver.ForkServer.set_forkserver_preload
128120
multiprocessing.managers.BaseListProxy.clear
129121
multiprocessing.managers.BaseListProxy.copy
130122
multiprocessing.managers._BaseDictProxy.__iter__
@@ -149,8 +141,6 @@ os.path.ALL_BUT_LAST
149141
os.path.__all__
150142
pathlib.PurePath.__vfspath__
151143
pathlib.PurePath.is_reserved
152-
pdb.Pdb.print_stack_entry
153-
pkgutil.resolve_name
154144
posixpath.ALL_BUT_LAST
155145
posixpath.__all__
156146
posixpath.basename
@@ -162,17 +152,9 @@ posixpath.split
162152
posixpath.splitdrive
163153
posixpath.splitext
164154
posixpath.splitroot
165-
pprint.PrettyPrinter.__init__
166-
pprint.pformat
167-
pprint.pprint
168-
site.addsitedir
169-
site.addsitepackages
170-
site.addusersitepackages
171-
site.process_startup_files
172155
sre_compile
173156
sre_constants
174157
sre_parse
175-
symtable.symtable
176158
sys.__jit
177159
sys._monitoring
178160
sys.last_exc

stdlib/ctypes/__init__.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,11 @@ def create_string_buffer(init: int | bytes, size: int | None = None) -> Array[c_
165165
c_buffer = create_string_buffer
166166

167167
def create_unicode_buffer(init: int | str, size: int | None = None) -> Array[c_wchar]: ...
168-
@deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
169-
def SetPointerType(pointer: type[_Pointer[Any]], cls: _CTypeBaseType) -> None: ...
168+
169+
if sys.version_info < (3, 15):
170+
@deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
171+
def SetPointerType(pointer: type[_Pointer[Any]], cls: _CTypeBaseType) -> None: ...
172+
170173
@deprecated("Soft deprecated since Python 3.13. Use multiplication instead.")
171174
def ARRAY(typ: _CT, len: int) -> Array[_CT]: ...
172175

stdlib/glob.pyi

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ __all__ = ["escape", "glob", "iglob"]
99
if sys.version_info >= (3, 13):
1010
__all__ += ["translate"]
1111

12-
@deprecated(
13-
"Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead."
14-
)
15-
def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
16-
@deprecated(
17-
"Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead."
18-
)
19-
def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
12+
if sys.version_info < (3, 15):
13+
@deprecated(
14+
"Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead."
15+
)
16+
def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
17+
@deprecated(
18+
"Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead."
19+
)
20+
def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
2021

2122
if sys.version_info >= (3, 11):
2223
def glob(

stdlib/gzip.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ class GzipFile(BaseStream):
167167
class _GzipReader(DecompressReader):
168168
def __init__(self, fp: _ReadableFileobj) -> None: ...
169169

170-
if sys.version_info >= (3, 14):
170+
if sys.version_info >= (3, 15):
171+
def compress(data: SizedBuffer, compresslevel: int = 6, *, mtime: float = 0) -> bytes: ...
172+
173+
elif sys.version_info >= (3, 14):
171174
def compress(data: SizedBuffer, compresslevel: int = 9, *, mtime: float = 0) -> bytes: ...
172175

173176
else:

stdlib/marshal.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ _Marshallable: TypeAlias = (
2727
| ReadableBuffer
2828
)
2929

30-
if sys.version_info >= (3, 14):
30+
if sys.version_info >= (3, 15):
31+
def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 6, /, *, allow_code: bool = True) -> None: ...
32+
def dumps(value: _Marshallable, version: int = 6, /, *, allow_code: bool = True) -> bytes: ...
33+
34+
elif sys.version_info >= (3, 14):
3135
def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 5, /, *, allow_code: bool = True) -> None: ...
3236
def dumps(value: _Marshallable, version: int = 5, /, *, allow_code: bool = True) -> bytes: ...
3337

stdlib/multiprocessing/context.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ class BaseContext:
123123
def log_to_stderr(self, level: _LoggingLevel | None = None) -> Logger: ...
124124
def allow_connection_pickling(self) -> None: ...
125125
def set_executable(self, executable: str) -> None: ...
126-
def set_forkserver_preload(self, module_names: list[str]) -> None: ...
126+
if sys.version_info >= (3, 15):
127+
def set_forkserver_preload(
128+
self, module_names: list[str], *, on_error: Literal["ignore", "warn", "fail"] = "ignore"
129+
) -> None: ...
130+
else:
131+
def set_forkserver_preload(self, module_names: list[str]) -> None: ...
132+
127133
@overload
128134
def get_context(self, method: None = None) -> DefaultContext: ...
129135
@overload

stdlib/multiprocessing/forkserver.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ import sys
22
from _typeshed import FileDescriptorLike, Unused
33
from collections.abc import Sequence
44
from struct import Struct
5-
from typing import Any, Final
5+
from typing import Any, Final, Literal
66

77
__all__ = ["ensure_running", "get_inherited_fds", "connect_to_new_process", "set_forkserver_preload"]
88

99
MAXFDS_TO_SEND: Final = 256
1010
SIGNED_STRUCT: Final[Struct]
1111

1212
class ForkServer:
13-
def set_forkserver_preload(self, modules_names: list[str]) -> None: ...
13+
if sys.version_info >= (3, 15):
14+
def set_forkserver_preload(
15+
self, modules_names: list[str], *, on_error: Literal["ignore", "warn", "fail"] = "ignore"
16+
) -> None: ...
17+
else:
18+
def set_forkserver_preload(self, modules_names: list[str]) -> None: ...
19+
1420
def get_inherited_fds(self) -> list[int] | None: ...
1521
def connect_to_new_process(self, fds: Sequence[int]) -> tuple[int, int]: ...
1622
def ensure_running(self) -> None: ...

stdlib/pdb.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ class Pdb(Bdb, Cmd):
136136
else:
137137
def print_stack_trace(self) -> None: ...
138138

139-
def print_stack_entry(self, frame_lineno: tuple[FrameType, int], prompt_prefix: str = "\n-> ") -> None: ...
139+
if sys.version_info >= (3, 15):
140+
def print_stack_entry(self, frame_lineno: tuple[FrameType, int], prompt_prefix: str | None = None) -> None: ...
141+
else:
142+
def print_stack_entry(self, frame_lineno: tuple[FrameType, int], prompt_prefix: str = "\n-> ") -> None: ...
143+
140144
def lookupmodule(self, filename: str) -> str | None: ...
141145
if sys.version_info < (3, 11):
142146
def _runscript(self, filename: str) -> None: ...

stdlib/pkgutil.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ def walk_packages(
5252
path: Iterable[StrOrBytesPath] | None = None, prefix: str = "", onerror: Callable[[str], object] | None = None
5353
) -> Iterator[ModuleInfo]: ...
5454
def get_data(package: str, resource: str) -> bytes | None: ...
55-
def resolve_name(name: str) -> Any: ...
55+
56+
if sys.version_info >= (3, 15):
57+
def resolve_name(name: str, *, strict: bool = False) -> Any: ...
58+
59+
else:
60+
def resolve_name(name: str) -> Any: ...

stdlib/pprint.pyi

Lines changed: 97 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,116 @@
1+
import sys
12
from _typeshed import SupportsWrite
23
from collections import deque
34
from typing import IO
45

56
__all__ = ["pprint", "pformat", "isreadable", "isrecursive", "saferepr", "PrettyPrinter", "pp"]
67

7-
def pformat(
8-
object: object,
9-
indent: int = 1,
10-
width: int = 80,
11-
depth: int | None = None,
12-
*,
13-
compact: bool = False,
14-
sort_dicts: bool = True,
15-
underscore_numbers: bool = False,
16-
) -> str: ...
17-
def pp(
18-
object: object,
19-
stream: IO[str] | None = None,
20-
indent: int = 1,
21-
width: int = 80,
22-
depth: int | None = None,
23-
*,
24-
compact: bool = False,
25-
sort_dicts: bool = False,
26-
underscore_numbers: bool = False,
27-
) -> None: ...
28-
def pprint(
29-
object: object,
30-
stream: IO[str] | None = None,
31-
indent: int = 1,
32-
width: int = 80,
33-
depth: int | None = None,
34-
*,
35-
compact: bool = False,
36-
sort_dicts: bool = True,
37-
underscore_numbers: bool = False,
38-
) -> None: ...
39-
def isreadable(object: object) -> bool: ...
40-
def isrecursive(object: object) -> bool: ...
41-
def saferepr(object: object) -> str: ...
8+
if sys.version_info >= (3, 15):
9+
def pformat(
10+
object: object,
11+
indent: int = 4,
12+
width: int = 88,
13+
depth: int | None = None,
14+
*,
15+
compact: bool = False,
16+
sort_dicts: bool = True,
17+
underscore_numbers: bool = False,
18+
) -> str: ...
4219

43-
class PrettyPrinter:
44-
def __init__(
45-
self,
20+
else:
21+
def pformat(
22+
object: object,
4623
indent: int = 1,
4724
width: int = 80,
4825
depth: int | None = None,
26+
*,
27+
compact: bool = False,
28+
sort_dicts: bool = True,
29+
underscore_numbers: bool = False,
30+
) -> str: ...
31+
32+
if sys.version_info >= (3, 15):
33+
def pp(
34+
object: object,
35+
stream: IO[str] | None = None,
36+
indent: int = 4,
37+
width: int = 88,
38+
depth: int | None = None,
39+
*,
40+
compact: bool = False,
41+
sort_dicts: bool = False,
42+
underscore_numbers: bool = False,
43+
) -> None: ...
44+
45+
else:
46+
def pp(
47+
object: object,
4948
stream: IO[str] | None = None,
49+
indent: int = 1,
50+
width: int = 80,
51+
depth: int | None = None,
52+
*,
53+
compact: bool = False,
54+
sort_dicts: bool = False,
55+
underscore_numbers: bool = False,
56+
) -> None: ...
57+
58+
if sys.version_info >= (3, 15):
59+
def pprint(
60+
object: object,
61+
stream: IO[str] | None = None,
62+
indent: int = 4,
63+
width: int = 88,
64+
depth: int | None = None,
65+
*,
66+
compact: bool = False,
67+
sort_dicts: bool = True,
68+
underscore_numbers: bool = False,
69+
) -> None: ...
70+
71+
else:
72+
def pprint(
73+
object: object,
74+
stream: IO[str] | None = None,
75+
indent: int = 1,
76+
width: int = 80,
77+
depth: int | None = None,
5078
*,
5179
compact: bool = False,
5280
sort_dicts: bool = True,
5381
underscore_numbers: bool = False,
5482
) -> None: ...
83+
84+
def isreadable(object: object) -> bool: ...
85+
def isrecursive(object: object) -> bool: ...
86+
def saferepr(object: object) -> str: ...
87+
88+
class PrettyPrinter:
89+
if sys.version_info >= (3, 15):
90+
def __init__(
91+
self,
92+
indent: int = 4,
93+
width: int = 88,
94+
depth: int | None = None,
95+
stream: IO[str] | None = None,
96+
*,
97+
compact: bool = False,
98+
sort_dicts: bool = True,
99+
underscore_numbers: bool = False,
100+
) -> None: ...
101+
else:
102+
def __init__(
103+
self,
104+
indent: int = 1,
105+
width: int = 80,
106+
depth: int | None = None,
107+
stream: IO[str] | None = None,
108+
*,
109+
compact: bool = False,
110+
sort_dicts: bool = True,
111+
underscore_numbers: bool = False,
112+
) -> None: ...
113+
55114
def pformat(self, object: object) -> str: ...
56115
def pprint(self, object: object) -> None: ...
57116
def isreadable(self, object: object) -> bool: ...

0 commit comments

Comments
 (0)