Skip to content

Commit f47ecad

Browse files
committed
Merge branch 'main' into fix_nonstring_suggestions2
2 parents 22ac8be + a3990df commit f47ecad

File tree

151 files changed

+4100
-2578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+4100
-2578
lines changed

Doc/c-api/intro.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ familiar with writing an extension before attempting to embed Python in a real
3030
application.
3131

3232

33+
Language version compatibility
34+
==============================
35+
36+
Python's C API is compatible with C11 and C++11 versions of C and C++.
37+
38+
This is a lower limit: the C API does not require features from later
39+
C/C++ versions.
40+
You do *not* need to enable your compiler's "c11 mode".
41+
42+
3343
Coding standards
3444
================
3545

Doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100

101101
# Minimum version of sphinx required
102102
# Keep this version in sync with ``Doc/requirements.txt``.
103-
needs_sphinx = '8.1.3'
103+
needs_sphinx = '8.2.0'
104104

105105
# Create table of contents entries for domain objects (e.g. functions, classes,
106106
# attributes, etc.). Default is True.

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ although there is currently no date scheduled for their removal.
127127

128128
* :class:`typing.Text` (:gh:`92332`).
129129

130+
* The internal class ``typing._UnionGenericAlias`` is no longer used to implement
131+
:class:`typing.Union`. To preserve compatibility with users using this private
132+
class, a compatibility shim will be provided until at least Python 3.17. (Contributed by
133+
Jelle Zijlstra in :gh:`105499`.)
134+
130135
* :class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a value
131136
that is not ``None`` from a test case.
132137

Doc/extending/embedding.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ interesting part with respect to embedding Python starts with ::
196196

197197
After initializing the interpreter, the script is loaded using
198198
:c:func:`PyImport_Import`. This routine needs a Python string as its argument,
199-
which is constructed using the :c:func:`PyUnicode_FromString` data conversion
200-
routine. ::
199+
which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data
200+
conversion routine. ::
201201

202202
pFunc = PyObject_GetAttrString(pModule, argv[2]);
203203
/* pFunc is a new reference */

Doc/library/functions.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,10 +1405,10 @@ are always available. They are listed here in alphabetical order.
14051405
:func:`io.TextIOWrapper.reconfigure`. When no *buffering* argument is
14061406
given, the default buffering policy works as follows:
14071407

1408-
* Binary files are buffered in fixed-size chunks; the size of the buffer is
1409-
chosen using a heuristic trying to determine the underlying device's "block
1410-
size" and falling back on :const:`io.DEFAULT_BUFFER_SIZE`. On many systems,
1411-
the buffer will typically be 4096 or 8192 bytes long.
1408+
* Binary files are buffered in fixed-size chunks; the size of the buffer
1409+
is ``max(min(blocksize, 8 MiB), DEFAULT_BUFFER_SIZE)``
1410+
when the device block size is available.
1411+
On most systems, the buffer will typically be 128 kilobytes long.
14121412

14131413
* "Interactive" text files (files for which :meth:`~io.IOBase.isatty`
14141414
returns ``True``) use line buffering. Other text files use the policy

Doc/library/functools.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ The :mod:`functools` module defines the following functions:
518518
... for i, elem in enumerate(arg):
519519
... print(i, elem)
520520

521-
:data:`types.UnionType` and :data:`typing.Union` can also be used::
521+
:class:`typing.Union` can also be used::
522522

523523
>>> @fun.register
524524
... def _(arg: int | float, verbose=False):
@@ -654,8 +654,8 @@ The :mod:`functools` module defines the following functions:
654654
The :func:`register` attribute now supports using type annotations.
655655

656656
.. versionchanged:: 3.11
657-
The :func:`register` attribute now supports :data:`types.UnionType`
658-
and :data:`typing.Union` as type annotations.
657+
The :func:`register` attribute now supports
658+
:class:`typing.Union` as a type annotation.
659659

660660

661661
.. class:: singledispatchmethod(func)

Doc/library/io.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,55 @@ Text I/O
11471147
It inherits from :class:`codecs.IncrementalDecoder`.
11481148

11491149

1150+
Static Typing
1151+
-------------
1152+
1153+
The following protocols can be used for annotating function and method
1154+
arguments for simple stream reading or writing operations. They are decorated
1155+
with :deco:`typing.runtime_checkable`.
1156+
1157+
.. class:: Reader[T]
1158+
1159+
Generic protocol for reading from a file or other input stream. ``T`` will
1160+
usually be :class:`str` or :class:`bytes`, but can be any type that is
1161+
read from the stream.
1162+
1163+
.. versionadded:: next
1164+
1165+
.. method:: read()
1166+
read(size, /)
1167+
1168+
Read data from the input stream and return it. If *size* is
1169+
specified, it should be an integer, and at most *size* items
1170+
(bytes/characters) will be read.
1171+
1172+
For example::
1173+
1174+
def read_it(reader: Reader[str]):
1175+
data = reader.read(11)
1176+
assert isinstance(data, str)
1177+
1178+
.. class:: Writer[T]
1179+
1180+
Generic protocol for writing to a file or other output stream. ``T`` will
1181+
usually be :class:`str` or :class:`bytes`, but can be any type that can be
1182+
written to the stream.
1183+
1184+
.. versionadded:: next
1185+
1186+
.. method:: write(data, /)
1187+
1188+
Write *data* to the output stream and return the number of items
1189+
(bytes/characters) written.
1190+
1191+
For example::
1192+
1193+
def write_binary(writer: Writer[bytes]):
1194+
writer.write(b"Hello world!\n")
1195+
1196+
See :ref:`typing-io` for other I/O related protocols and classes that can be
1197+
used for static type checking.
1198+
11501199
Performance
11511200
-----------
11521201

Doc/library/pdb.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ access further features, you have to do this yourself:
245245
.. versionadded:: 3.14
246246
Added the *mode* argument.
247247

248+
.. versionchanged:: 3.14
249+
Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will
250+
always stop the program at calling frame, ignoring the *skip* pattern (if any).
251+
248252
.. method:: run(statement, globals=None, locals=None)
249253
runeval(expression, globals=None, locals=None)
250254
runcall(function, *args, **kwds)

Doc/library/stdtypes.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5364,7 +5364,7 @@ Union Type
53645364
A union object holds the value of the ``|`` (bitwise or) operation on
53655365
multiple :ref:`type objects <bltin-type-objects>`. These types are intended
53665366
primarily for :term:`type annotations <annotation>`. The union type expression
5367-
enables cleaner type hinting syntax compared to :data:`typing.Union`.
5367+
enables cleaner type hinting syntax compared to subscripting :class:`typing.Union`.
53685368

53695369
.. describe:: X | Y | ...
53705370

@@ -5400,9 +5400,10 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
54005400

54015401
int | str == str | int
54025402

5403-
* It is compatible with :data:`typing.Union`::
5403+
* It creates instances of :class:`typing.Union`::
54045404

54055405
int | str == typing.Union[int, str]
5406+
type(int | str) is typing.Union
54065407

54075408
* Optional types can be spelled as a union with ``None``::
54085409

@@ -5428,16 +5429,15 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
54285429
TypeError: isinstance() argument 2 cannot be a parameterized generic
54295430

54305431
The user-exposed type for the union object can be accessed from
5431-
:data:`types.UnionType` and used for :func:`isinstance` checks. An object cannot be
5432-
instantiated from the type::
5432+
:class:`typing.Union` and used for :func:`isinstance` checks::
54335433

5434-
>>> import types
5435-
>>> isinstance(int | str, types.UnionType)
5434+
>>> import typing
5435+
>>> isinstance(int | str, typing.Union)
54365436
True
5437-
>>> types.UnionType()
5437+
>>> typing.Union()
54385438
Traceback (most recent call last):
54395439
File "<stdin>", line 1, in <module>
5440-
TypeError: cannot create 'types.UnionType' instances
5440+
TypeError: cannot create 'typing.Union' instances
54415441

54425442
.. note::
54435443
The :meth:`!__or__` method for type objects was added to support the syntax
@@ -5464,6 +5464,11 @@ instantiated from the type::
54645464

54655465
.. versionadded:: 3.10
54665466

5467+
.. versionchanged:: 3.14
5468+
5469+
Union objects are now instances of :class:`typing.Union`. Previously, they were instances
5470+
of :class:`types.UnionType`, which remains an alias for :class:`typing.Union`.
5471+
54675472

54685473
.. _typesother:
54695474

Doc/library/types.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ Standard names are defined for the following types:
314314

315315
.. versionadded:: 3.10
316316

317+
.. versionchanged:: 3.14
318+
319+
This is now an alias for :class:`typing.Union`.
320+
317321
.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)
318322

319323
The type of traceback objects such as found in ``sys.exception().__traceback__``.

0 commit comments

Comments
 (0)