Skip to content

Commit 8dac531

Browse files
committed
Merge remote-tracking branch 'cpython/main' into fix-issue-29842
2 parents 7b1d5f6 + 98fa4a4 commit 8dac531

File tree

190 files changed

+5668
-3522
lines changed

Some content is hidden

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

190 files changed

+5668
-3522
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: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,34 @@ The debugger's prompt is ``(Pdb)``, which is the indicator that you are in debug
7575
arguments of the ``p`` command.
7676

7777

78+
.. program:: pdb
79+
7880
You can also invoke :mod:`pdb` from the command line to debug other scripts. For
7981
example::
8082

81-
python -m pdb myscript.py
83+
python -m pdb [-c command] (-m module | pyfile) [args ...]
8284

8385
When invoked as a module, pdb will automatically enter post-mortem debugging if
8486
the program being debugged exits abnormally. After post-mortem debugging (or
8587
after normal exit of the program), pdb will restart the program. Automatic
8688
restarting preserves pdb's state (such as breakpoints) and in most cases is more
8789
useful than quitting the debugger upon program's exit.
8890

89-
.. versionchanged:: 3.2
90-
Added the ``-c`` option to execute commands as if given
91-
in a :file:`.pdbrc` file; see :ref:`debugger-commands`.
91+
.. option:: -c, --command <command>
9292

93-
.. versionchanged:: 3.7
94-
Added the ``-m`` option to execute modules similar to the way
95-
``python -m`` does. As with a script, the debugger will pause execution just
96-
before the first line of the module.
93+
To execute commands as if given in a :file:`.pdbrc` file; see
94+
:ref:`debugger-commands`.
95+
96+
.. versionchanged:: 3.2
97+
Added the ``-c`` option.
98+
99+
.. option:: -m <module>
100+
101+
To execute modules similar to the way ``python -m`` does. As with a script,
102+
the debugger will pause execution just before the first line of the module.
103+
104+
.. versionchanged:: 3.7
105+
Added the ``-m`` option.
97106

98107
Typical usage to execute a statement under control of the debugger is::
99108

@@ -245,6 +254,10 @@ access further features, you have to do this yourself:
245254
.. versionadded:: 3.14
246255
Added the *mode* argument.
247256

257+
.. versionchanged:: 3.14
258+
Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will
259+
always stop the program at calling frame, ignoring the *skip* pattern (if any).
260+
248261
.. method:: run(statement, globals=None, locals=None)
249262
runeval(expression, globals=None, locals=None)
250263
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/time.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ An explanation of some terminology and conventions is in order.
5252
single: Coordinated Universal Time
5353
single: Greenwich Mean Time
5454

55-
* UTC is Coordinated Universal Time (formerly known as Greenwich Mean Time, or
56-
GMT). The acronym UTC is not a mistake but a compromise between English and
57-
French.
55+
* UTC is `Coordinated Universal Time`_ and superseded `Greenwich Mean Time`_ or
56+
GMT as the basis of international timekeeping. The acronym UTC is not a
57+
mistake but conforms to an earlier, language-agnostic naming scheme for time
58+
standards such as UT0, UT1, and UT2.
59+
60+
.. _Coordinated Universal Time: https://en.wikipedia.org/wiki/Coordinated_Universal_Time
61+
.. _Greenwich Mean Time: https://en.wikipedia.org/wiki/Greenwich_Mean_Time
5862

5963
.. index:: single: Daylight Saving Time
6064

0 commit comments

Comments
 (0)