Skip to content

Commit 91366d8

Browse files
Merge branch 'main' into long-from-dev_t
2 parents acd102e + f108468 commit 91366d8

File tree

253 files changed

+5468
-6860
lines changed

Some content is hidden

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

253 files changed

+5468
-6860
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ Programs/test_frozenmain.h generated
9494
Python/Python-ast.c generated
9595
Python/executor_cases.c.h generated
9696
Python/generated_cases.c.h generated
97-
Python/abstract_interp_cases.c.h generated
9897
Python/opcode_targets.h generated
9998
Python/stdlib_module_names.h generated
10099
Tools/peg_generator/pegen/grammar_parser.py generated

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ Doc/c-api/stable.rst @encukou
157157

158158
**/*dataclasses* @ericvsmith
159159

160+
**/*ensurepip* @pfmoore @pradyunsg
161+
160162
**/*idlelib* @terryjreedy
161163

162164
**/*typing* @JelleZijlstra @AlexWaygood

Doc/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ SPHINXERRORHANDLING = -W
1919
PAPEROPT_a4 = -D latex_elements.papersize=a4paper
2020
PAPEROPT_letter = -D latex_elements.papersize=letterpaper
2121

22-
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j $(JOBS) \
23-
$(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
22+
ALLSPHINXOPTS = -b $(BUILDER) \
23+
-d build/doctrees \
24+
-j $(JOBS) \
25+
$(PAPEROPT_$(PAPER)) \
26+
$(SPHINXOPTS) $(SPHINXERRORHANDLING) \
27+
. build/$(BUILDER) $(SOURCES)
2428

2529
.PHONY: help
2630
help:
@@ -142,7 +146,7 @@ htmlview: html
142146

143147
.PHONY: htmllive
144148
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
145-
htmllive: SPHINXOPTS = --re-ignore="/venv/"
149+
htmllive: SPHINXOPTS = --re-ignore="/venv/" --open-browser --delay 0
146150
htmllive: html
147151

148152
.PHONY: clean

Doc/howto/isolating-extensions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ That is, heap types should:
337337

338338
- Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag.
339339
- Define a traverse function using ``Py_tp_traverse``, which
340-
visits the type (e.g. using :c:expr:`Py_VISIT(Py_TYPE(self))`).
340+
visits the type (e.g. using ``Py_VISIT(Py_TYPE(self))``).
341341

342342
Please refer to the the documentation of
343343
:c:macro:`Py_TPFLAGS_HAVE_GC` and :c:member:`~PyTypeObject.tp_traverse`
@@ -482,7 +482,7 @@ The largest roadblock is getting *the class a method was defined in*, or
482482
that method's "defining class" for short. The defining class can have a
483483
reference to the module it is part of.
484484

485-
Do not confuse the defining class with :c:expr:`Py_TYPE(self)`. If the method
485+
Do not confuse the defining class with ``Py_TYPE(self)``. If the method
486486
is called on a *subclass* of your type, ``Py_TYPE(self)`` will refer to
487487
that subclass, which may be defined in different module than yours.
488488

Doc/howto/logging-cookbook.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ Suppose you configure logging with the following JSON:
332332
}
333333
}
334334
335-
This configuration does *almost* what we want, except that ``sys.stdout`` would
336-
show messages of severity ``ERROR`` and above as well as ``INFO`` and
337-
``WARNING`` messages. To prevent this, we can set up a filter which excludes
338-
those messages and add it to the relevant handler. This can be configured by
335+
This configuration does *almost* what we want, except that ``sys.stdout`` would show messages
336+
of severity ``ERROR`` and only events of this severity and higher will be tracked
337+
as well as ``INFO`` and ``WARNING`` messages. To prevent this, we can set up a filter which
338+
excludes those messages and add it to the relevant handler. This can be configured by
339339
adding a ``filters`` section parallel to ``formatters`` and ``handlers``:
340340

341341
.. code-block:: json

Doc/howto/logging.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ described below (in increasing order of severity):
8989
| | itself may be unable to continue running. |
9090
+--------------+---------------------------------------------+
9191

92-
The default level is ``WARNING``, which means that only events of this level
93-
and above will be tracked, unless the logging package is configured to do
94-
otherwise.
92+
The default level is ``WARNING``, which means that only events of this severity and higher
93+
will be tracked, unless the logging package is configured to do otherwise.
9594

9695
Events that are tracked can be handled in different ways. The simplest way of
9796
handling tracked events is to print them to the console. Another common way

Doc/library/ast.rst

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Node classes
4545

4646
This is the base of all AST node classes. The actual node classes are
4747
derived from the :file:`Parser/Python.asdl` file, which is reproduced
48-
:ref:`above <abstract-grammar>`. They are defined in the :mod:`_ast` C
48+
:ref:`above <abstract-grammar>`. They are defined in the :mod:`!_ast` C
4949
module and re-exported in :mod:`ast`.
5050

5151
There is one class defined for each left-hand side symbol in the abstract
@@ -128,14 +128,14 @@ Node classes
128128

129129
.. deprecated:: 3.8
130130

131-
Old classes :class:`ast.Num`, :class:`ast.Str`, :class:`ast.Bytes`,
132-
:class:`ast.NameConstant` and :class:`ast.Ellipsis` are still available,
131+
Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!ast.Bytes`,
132+
:class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still available,
133133
but they will be removed in future Python releases. In the meantime,
134134
instantiating them will return an instance of a different class.
135135

136136
.. deprecated:: 3.9
137137

138-
Old classes :class:`ast.Index` and :class:`ast.ExtSlice` are still
138+
Old classes :class:`!ast.Index` and :class:`!ast.ExtSlice` are still
139139
available, but they will be removed in future Python releases.
140140
In the meantime, instantiating them will return an instance of
141141
a different class.
@@ -1935,8 +1935,7 @@ Function and class definitions
19351935
.. class:: arg(arg, annotation, type_comment)
19361936

19371937
A single argument in a list. ``arg`` is a raw string of the argument
1938-
name, ``annotation`` is its annotation, such as a :class:`Str` or
1939-
:class:`Name` node.
1938+
name; ``annotation`` is its annotation, such as a :class:`Name` node.
19401939

19411940
.. attribute:: type_comment
19421941

@@ -2210,7 +2209,7 @@ and classes for traversing abstract syntax trees:
22102209
Added ``type_comments``, ``mode='func_type'`` and ``feature_version``.
22112210

22122211
.. versionchanged:: 3.13
2213-
The minimum supported version for feature_version is now (3,7)
2212+
The minimum supported version for ``feature_version`` is now ``(3, 7)``.
22142213
The ``optimize`` argument was added.
22152214

22162215

@@ -2286,8 +2285,8 @@ and classes for traversing abstract syntax trees:
22862285
.. function:: get_source_segment(source, node, *, padded=False)
22872286

22882287
Get source code segment of the *source* that generated *node*.
2289-
If some location information (:attr:`lineno`, :attr:`end_lineno`,
2290-
:attr:`col_offset`, or :attr:`end_col_offset`) is missing, return ``None``.
2288+
If some location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`,
2289+
:attr:`~ast.AST.col_offset`, or :attr:`~ast.AST.end_col_offset`) is missing, return ``None``.
22912290

22922291
If *padded* is ``True``, the first line of a multi-line statement will
22932292
be padded with spaces to match its original position.
@@ -2298,7 +2297,7 @@ and classes for traversing abstract syntax trees:
22982297
.. function:: fix_missing_locations(node)
22992298

23002299
When you compile a node tree with :func:`compile`, the compiler expects
2301-
:attr:`lineno` and :attr:`col_offset` attributes for every node that supports
2300+
:attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes for every node that supports
23022301
them. This is rather tedious to fill in for generated nodes, so this helper
23032302
adds these attributes recursively where not already set, by setting them to
23042303
the values of the parent node. It works recursively starting at *node*.
@@ -2313,8 +2312,8 @@ and classes for traversing abstract syntax trees:
23132312

23142313
.. function:: copy_location(new_node, old_node)
23152314

2316-
Copy source location (:attr:`lineno`, :attr:`col_offset`, :attr:`end_lineno`,
2317-
and :attr:`end_col_offset`) from *old_node* to *new_node* if possible,
2315+
Copy source location (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :attr:`~ast.AST.end_lineno`,
2316+
and :attr:`~ast.AST.end_col_offset`) from *old_node* to *new_node* if possible,
23182317
and return *new_node*.
23192318

23202319

@@ -2360,14 +2359,18 @@ and classes for traversing abstract syntax trees:
23602359
visited unless the visitor calls :meth:`generic_visit` or visits them
23612360
itself.
23622361

2362+
.. method:: visit_Constant(node)
2363+
2364+
Handles all constant nodes.
2365+
23632366
Don't use the :class:`NodeVisitor` if you want to apply changes to nodes
23642367
during traversal. For this a special visitor exists
23652368
(:class:`NodeTransformer`) that allows modifications.
23662369

23672370
.. deprecated:: 3.8
23682371

2369-
Methods :meth:`visit_Num`, :meth:`visit_Str`, :meth:`visit_Bytes`,
2370-
:meth:`visit_NameConstant` and :meth:`visit_Ellipsis` are deprecated
2372+
Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`,
2373+
:meth:`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated
23712374
now and will not be called in future Python versions. Add the
23722375
:meth:`visit_Constant` method to handle all constant nodes.
23732376

@@ -2396,7 +2399,7 @@ and classes for traversing abstract syntax trees:
23962399
)
23972400

23982401
Keep in mind that if the node you're operating on has child nodes you must
2399-
either transform the child nodes yourself or call the :meth:`generic_visit`
2402+
either transform the child nodes yourself or call the :meth:`~ast.NodeVisitor.generic_visit`
24002403
method for the node first.
24012404

24022405
For nodes that were part of a collection of statements (that applies to all
@@ -2405,7 +2408,7 @@ and classes for traversing abstract syntax trees:
24052408

24062409
If :class:`NodeTransformer` introduces new nodes (that weren't part of
24072410
original tree) without giving them location information (such as
2408-
:attr:`lineno`), :func:`fix_missing_locations` should be called with
2411+
:attr:`~ast.AST.lineno`), :func:`fix_missing_locations` should be called with
24092412
the new sub-tree to recalculate the location information::
24102413

24112414
tree = ast.parse('foo', mode='eval')
@@ -2457,6 +2460,13 @@ effects on the compilation of a program:
24572460
Generates and returns an abstract syntax tree instead of returning a
24582461
compiled code object.
24592462

2463+
.. data:: PyCF_OPTIMIZED_AST
2464+
2465+
The returned AST is optimized according to the *optimize* argument
2466+
in :func:`compile` or :func:`ast.parse`.
2467+
2468+
.. versionadded:: 3.13
2469+
24602470
.. data:: PyCF_TYPE_COMMENTS
24612471

24622472
Enables support for :pep:`484` and :pep:`526` style type comments

Doc/library/bisect.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ linear searches or frequent resorting.
1919
The module is called :mod:`bisect` because it uses a basic bisection
2020
algorithm to do its work. Unlike other bisection tools that search for a
2121
specific value, the functions in this module are designed to locate an
22-
insertion point. Accordingly, the functions never call an :meth:`__eq__`
22+
insertion point. Accordingly, the functions never call an :meth:`~object.__eq__`
2323
method to determine whether a value has been found. Instead, the
24-
functions only call the :meth:`__lt__` method and will return an insertion
24+
functions only call the :meth:`~object.__lt__` method and will return an insertion
2525
point between values in an array.
2626

2727
.. _bisect functions:
@@ -73,7 +73,7 @@ The following functions are provided:
7373
Insert *x* in *a* in sorted order.
7474

7575
This function first runs :py:func:`~bisect.bisect_left` to locate an insertion point.
76-
Next, it runs the :meth:`insert` method on *a* to insert *x* at the
76+
Next, it runs the :meth:`!insert` method on *a* to insert *x* at the
7777
appropriate position to maintain sort order.
7878

7979
To support inserting records in a table, the *key* function (if any) is
@@ -93,7 +93,7 @@ The following functions are provided:
9393
entries of *x*.
9494

9595
This function first runs :py:func:`~bisect.bisect_right` to locate an insertion point.
96-
Next, it runs the :meth:`insert` method on *a* to insert *x* at the
96+
Next, it runs the :meth:`!insert` method on *a* to insert *x* at the
9797
appropriate position to maintain sort order.
9898

9999
To support inserting records in a table, the *key* function (if any) is

Doc/library/calendar.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
196196
output (defaulting to the system default encoding).
197197

198198

199+
.. method:: formatmonthname(theyear, themonth, withyear=True)
200+
201+
Return a month name as an HTML table row. If *withyear* is true the year
202+
will be included in the row, otherwise just the month name will be
203+
used.
204+
205+
199206
:class:`!HTMLCalendar` has the following attributes you can override to
200207
customize the CSS classes used by the calendar:
201208

@@ -289,7 +296,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
289296

290297
.. note::
291298

292-
The constructor, :meth:`formatweekday` and :meth:`formatmonthname` methods
299+
The constructor, :meth:`!formatweekday` and :meth:`!formatmonthname` methods
293300
of these two classes temporarily change the ``LC_TIME`` locale to the given
294301
*locale*. Because the current locale is a process-wide setting, they are
295302
not thread-safe.
@@ -358,7 +365,7 @@ For simple text calendars this module provides the following functions.
358365

359366
.. function:: month(theyear, themonth, w=0, l=0)
360367

361-
Returns a month's calendar in a multi-line string using the :meth:`formatmonth`
368+
Returns a month's calendar in a multi-line string using the :meth:`~TextCalendar.formatmonth`
362369
of the :class:`TextCalendar` class.
363370

364371

@@ -370,7 +377,7 @@ For simple text calendars this module provides the following functions.
370377
.. function:: calendar(year, w=2, l=1, c=6, m=3)
371378

372379
Returns a 3-column calendar for an entire year as a multi-line string using
373-
the :meth:`formatyear` of the :class:`TextCalendar` class.
380+
the :meth:`~TextCalendar.formatyear` of the :class:`TextCalendar` class.
374381

375382

376383
.. function:: timegm(tuple)

Doc/library/cmd.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,30 @@ A :class:`Cmd` instance has the following methods:
7676
single: ! (exclamation); in a command interpreter
7777

7878
An interpreter instance will recognize a command name ``foo`` if and only if it
79-
has a method :meth:`do_foo`. As a special case, a line beginning with the
79+
has a method :meth:`!do_foo`. As a special case, a line beginning with the
8080
character ``'?'`` is dispatched to the method :meth:`do_help`. As another
8181
special case, a line beginning with the character ``'!'`` is dispatched to the
82-
method :meth:`do_shell` (if such a method is defined).
82+
method :meth:`!do_shell` (if such a method is defined).
8383

8484
This method will return when the :meth:`postcmd` method returns a true value.
8585
The *stop* argument to :meth:`postcmd` is the return value from the command's
8686
corresponding :meth:`!do_\*` method.
8787

8888
If completion is enabled, completing commands will be done automatically, and
89-
completing of commands args is done by calling :meth:`complete_foo` with
89+
completing of commands args is done by calling :meth:`!complete_foo` with
9090
arguments *text*, *line*, *begidx*, and *endidx*. *text* is the string prefix
9191
we are attempting to match: all returned matches must begin with it. *line* is
9292
the current input line with leading whitespace removed, *begidx* and *endidx*
9393
are the beginning and ending indexes of the prefix text, which could be used to
9494
provide different completion depending upon which position the argument is in.
9595

96-
All subclasses of :class:`Cmd` inherit a predefined :meth:`do_help`. This
96+
97+
.. method:: Cmd.do_help(arg)
98+
99+
All subclasses of :class:`Cmd` inherit a predefined :meth:`!do_help`. This
97100
method, called with an argument ``'bar'``, invokes the corresponding method
98-
:meth:`help_bar`, and if that is not present, prints the docstring of
99-
:meth:`do_bar`, if available. With no argument, :meth:`do_help` lists all
101+
:meth:`!help_bar`, and if that is not present, prints the docstring of
102+
:meth:`!do_bar`, if available. With no argument, :meth:`!do_help` lists all
100103
available help topics (that is, all commands with corresponding
101104
:meth:`!help_\*` methods or commands that have docstrings), and also lists any
102105
undocumented commands.
@@ -229,8 +232,8 @@ Instances of :class:`Cmd` subclasses have some public instance variables:
229232
.. attribute:: Cmd.use_rawinput
230233

231234
A flag, defaulting to true. If true, :meth:`cmdloop` uses :func:`input` to
232-
display a prompt and read the next command; if false, :meth:`sys.stdout.write`
233-
and :meth:`sys.stdin.readline` are used. (This means that by importing
235+
display a prompt and read the next command; if false, :data:`sys.stdout.write() <sys.stdout>`
236+
and :data:`sys.stdin.readline() <sys.stdin>` are used. (This means that by importing
234237
:mod:`readline`, on systems that support it, the interpreter will automatically
235238
support :program:`Emacs`\ -like line editing and command-history keystrokes.)
236239

@@ -249,14 +252,14 @@ This section presents a simple example of how to build a shell around a few of
249252
the commands in the :mod:`turtle` module.
250253

251254
Basic turtle commands such as :meth:`~turtle.forward` are added to a
252-
:class:`Cmd` subclass with method named :meth:`do_forward`. The argument is
255+
:class:`Cmd` subclass with method named :meth:`!do_forward`. The argument is
253256
converted to a number and dispatched to the turtle module. The docstring is
254257
used in the help utility provided by the shell.
255258

256259
The example also includes a basic record and playback facility implemented with
257260
the :meth:`~Cmd.precmd` method which is responsible for converting the input to
258-
lowercase and writing the commands to a file. The :meth:`do_playback` method
259-
reads the file and adds the recorded commands to the :attr:`cmdqueue` for
261+
lowercase and writing the commands to a file. The :meth:`!do_playback` method
262+
reads the file and adds the recorded commands to the :attr:`~Cmd.cmdqueue` for
260263
immediate playback::
261264

262265
import cmd, sys

Doc/library/collections.abc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ the required methods (unless those methods have been set to
8787

8888
class E:
8989
def __iter__(self): ...
90-
def __next__(next): ...
90+
def __next__(self): ...
9191

9292
.. doctest::
9393

Doc/library/datetime.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,8 @@ Other constructor:
17991799

18001800
Examples::
18011801

1802+
.. doctest::
1803+
18021804
>>> from datetime import time
18031805
>>> time.fromisoformat('04:23:01')
18041806
datetime.time(4, 23, 1)
@@ -1808,7 +1810,7 @@ Other constructor:
18081810
datetime.time(4, 23, 1)
18091811
>>> time.fromisoformat('04:23:01.000384')
18101812
datetime.time(4, 23, 1, 384)
1811-
>>> time.fromisoformat('04:23:01,000')
1813+
>>> time.fromisoformat('04:23:01,000384')
18121814
datetime.time(4, 23, 1, 384)
18131815
>>> time.fromisoformat('04:23:01+04:00')
18141816
datetime.time(4, 23, 1, tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))

Doc/library/dbm.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ This module can be used with the "classic" ndbm interface or the GNU GDBM
272272
compatibility interface. On Unix, the :program:`configure` script will attempt
273273
to locate the appropriate header file to simplify building this module.
274274

275+
.. warning::
276+
277+
The ndbm library shipped as part of macOS has an undocumented limitation on the
278+
size of values, which can result in corrupted database files
279+
when storing values larger than this limit. Reading such corrupted files can
280+
result in a hard crash (segmentation fault).
281+
275282
.. exception:: error
276283

277284
Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:`KeyError` is raised

0 commit comments

Comments
 (0)