Skip to content

Commit 4d61963

Browse files
authored
Merge branch 'python:main' into main
2 parents c564186 + e6391e0 commit 4d61963

File tree

93 files changed

+2459
-1591
lines changed

Some content is hidden

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

93 files changed

+2459
-1591
lines changed

Doc/c-api/typeobj.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,11 +2523,11 @@ Slot Type typedefs
25232523

25242524
.. c:type:: PyObject *(*descrgetfunc)(PyObject *, PyObject *, PyObject *)
25252525
2526-
See :c:member:`~PyTypeObject.tp_descrget`.
2526+
See :c:member:`~PyTypeObject.tp_descr_get`.
25272527

25282528
.. c:type:: int (*descrsetfunc)(PyObject *, PyObject *, PyObject *)
25292529
2530-
See :c:member:`~PyTypeObject.tp_descrset`.
2530+
See :c:member:`~PyTypeObject.tp_descr_set`.
25312531

25322532
.. c:type:: Py_hash_t (*hashfunc)(PyObject *)
25332533

Doc/faq/programming.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,9 @@ What is the difference between arguments and parameters?
409409

410410
:term:`Parameters <parameter>` are defined by the names that appear in a
411411
function definition, whereas :term:`arguments <argument>` are the values
412-
actually passed to a function when calling it. Parameters define what types of
413-
arguments a function can accept. For example, given the function definition::
412+
actually passed to a function when calling it. Parameters define what
413+
:term:`kind of arguments <parameter>` a function can accept. For
414+
example, given the function definition::
414415

415416
def func(foo, bar=None, **kwargs):
416417
pass

Doc/library/dis.rst

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,13 @@ result back on the stack.
446446

447447
**Binary and in-place operations**
448448

449-
Binary operations remove the top of the stack (TOS) and the second top-most
450-
stack item (TOS1) from the stack. They perform the operation, and put the
451-
result back on the stack.
449+
In the following, TOS is the top-of-stack.
450+
TOS1, TOS2, TOS3 are the second, thrid and fourth items on the stack, respectively.
451+
452+
Binary operations remove the top two items from the stack (TOS and TOS1).
453+
They perform the operation, then put the result back on the stack.
452454

453-
In-place operations are like binary operations, in that they remove TOS and
454-
TOS1, and push the result back on the stack, but the operation is done in-place
455+
In-place operations are like binary operations, but the operation is done in-place
455456
when TOS1 supports it, and the resulting TOS may be (but does not have to be)
456457
the original TOS1.
457458

@@ -460,6 +461,7 @@ the original TOS1.
460461

461462
Implements the binary and in-place operators (depending on the value of
462463
*op*).
464+
``TOS = TOS1 op TOS``.
463465

464466
.. versionadded:: 3.11
465467

@@ -479,6 +481,20 @@ the original TOS1.
479481
Implements ``del TOS1[TOS]``.
480482

481483

484+
.. opcode:: BINARY_SLICE
485+
486+
Implements ``TOS = TOS2[TOS1:TOS]``.
487+
488+
.. versionadded:: 3.12
489+
490+
491+
.. opcode:: STORE_SLICE
492+
493+
Implements ``TOS2[TOS1:TOS] = TOS3``.
494+
495+
.. versionadded:: 3.12
496+
497+
482498
**Coroutine opcodes**
483499

484500
.. opcode:: GET_AWAITABLE (where)
@@ -512,8 +528,8 @@ the original TOS1.
512528

513529
.. opcode:: GET_ANEXT
514530

515-
Implements ``PUSH(get_awaitable(TOS.__anext__()))``. See ``GET_AWAITABLE``
516-
for details about ``get_awaitable``
531+
Pushes ``get_awaitable(TOS.__anext__())`` to the stack. See
532+
``GET_AWAITABLE`` for details about ``get_awaitable``.
517533

518534
.. versionadded:: 3.5
519535

Doc/library/idle.rst

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ for more on Help menu choices.
357357
single: Clear Breakpoint
358358
single: breakpoints
359359

360-
Context Menus
360+
Context menus
361361
^^^^^^^^^^^^^^^^^^^^^^^^^^
362362

363363
Open a context menu by right-clicking in a window (Control-click on macOS).
@@ -398,7 +398,7 @@ Squeeze
398398

399399
.. _editing-and-navigation:
400400

401-
Editing and navigation
401+
Editing and Navigation
402402
----------------------
403403

404404
Editor windows
@@ -576,17 +576,29 @@ line to the top of the editor.
576576
The text and background colors for the context pane can be configured under
577577
the Highlights tab in the Configure IDLE dialog.
578578

579-
Python Shell window
580-
^^^^^^^^^^^^^^^^^^^
579+
Shell window
580+
^^^^^^^^^^^^
581581

582-
With IDLE's Shell, one enters, edits, and recalls complete statements.
583-
Most consoles and terminals only work with a single physical line at a time.
582+
In IDLE's Shell, enter, edit, and recall complete statements. (Most
583+
consoles and terminals only work with a single physical line at a time).
584+
585+
Submit a single-line statement for execution by hitting :kbd:`Return`
586+
with the cursor anywhere on the line. If a line is extended with
587+
Backslash (:kbd:`\\`), the cursor must be on the last physical line.
588+
Submit a multi-line compound statement by entering a blank line after
589+
the statement.
584590

585591
When one pastes code into Shell, it is not compiled and possibly executed
586-
until one hits :kbd:`Return`. One may edit pasted code first.
587-
If one pastes more that one statement into Shell, the result will be a
592+
until one hits :kbd:`Return`, as specified above.
593+
One may edit pasted code first.
594+
If one pastes more than one statement into Shell, the result will be a
588595
:exc:`SyntaxError` when multiple statements are compiled as if they were one.
589596

597+
Lines containing`'RESTART'` mean that the user execution process has been
598+
re-started. This occurs when the user execution process has crashed,
599+
when one requests a restart on the Shell menu, or when one runs code
600+
in an editor window.
601+
590602
The editing features described in previous subsections work when entering
591603
code interactively. IDLE's Shell window also responds to the following keys.
592604

@@ -603,7 +615,8 @@ code interactively. IDLE's Shell window also responds to the following keys.
603615

604616
* :kbd:`Alt-n` retrieves next. On macOS use :kbd:`C-n`.
605617

606-
* :kbd:`Return` while on any previous command retrieves that command
618+
* :kbd:`Return` while the cursor is on any previous command
619+
retrieves that command
607620

608621
Text colors
609622
^^^^^^^^^^^
@@ -627,7 +640,7 @@ Highlighting tab. The marking of debugger breakpoint lines in the editor and
627640
text in popups and dialogs is not user-configurable.
628641

629642

630-
Startup and code execution
643+
Startup and Code Execution
631644
--------------------------
632645

633646
Upon startup with the ``-s`` option, IDLE will execute the file referenced by
@@ -894,7 +907,7 @@ with the default subprocess if at all possible.
894907
.. deprecated:: 3.4
895908

896909

897-
Help and preferences
910+
Help and Preferences
898911
--------------------
899912

900913
.. _help-sources:

Doc/library/importlib.metadata.rst

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
**Source code:** :source:`Lib/importlib/metadata/__init__.py`
1515

16-
``importlib.metadata`` is a library that provides for access to installed
17-
package metadata. Built in part on Python's import system, this library
16+
``importlib.metadata`` is a library that provides access to installed
17+
package metadata, such as its entry points or its
18+
top-level name. Built in part on Python's import system, this library
1819
intends to replace similar functionality in the `entry point
1920
API`_ and `metadata API`_ of ``pkg_resources``. Along with
20-
:mod:`importlib.resources` (with new features backported to the
21-
`importlib_resources`_ package), this can eliminate the need to use the older
22-
and less efficient
21+
:mod:`importlib.resources`,
22+
this package can eliminate the need to use the older and less efficient
2323
``pkg_resources`` package.
2424

2525
By "installed package" we generally mean a third-party package installed into
@@ -32,6 +32,13 @@ By default, package metadata can live on the file system or in zip archives on
3232
anywhere.
3333

3434

35+
.. seealso::
36+
37+
https://importlib-metadata.readthedocs.io/
38+
The documentation for ``importlib_metadata``, which supplies a
39+
backport of ``importlib.metadata``.
40+
41+
3542
Overview
3643
========
3744

@@ -54,9 +61,9 @@ You can get the version string for ``wheel`` by running the following:
5461
>>> version('wheel') # doctest: +SKIP
5562
'0.32.3'
5663
57-
You can also get the set of entry points keyed by group, such as
64+
You can also get a collection of entry points selectable by properties of the EntryPoint (typically 'group' or 'name'), such as
5865
``console_scripts``, ``distutils.commands`` and others. Each group contains a
59-
sequence of :ref:`EntryPoint <entry-points>` objects.
66+
collection of :ref:`EntryPoint <entry-points>` objects.
6067

6168
You can get the :ref:`metadata for a distribution <metadata>`::
6269

@@ -91,7 +98,7 @@ Query all entry points::
9198
>>> eps = entry_points() # doctest: +SKIP
9299

93100
The ``entry_points()`` function returns an ``EntryPoints`` object,
94-
a sequence of all ``EntryPoint`` objects with ``names`` and ``groups``
101+
a collection of all ``EntryPoint`` objects with ``names`` and ``groups``
95102
attributes for convenience::
96103

97104
>>> sorted(eps.groups) # doctest: +SKIP
@@ -174,6 +181,13 @@ all the metadata in a JSON-compatible form per :PEP:`566`::
174181
>>> wheel_metadata.json['requires_python']
175182
'>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'
176183

184+
.. note::
185+
186+
The actual type of the object returned by ``metadata()`` is an
187+
implementation detail and should be accessed only through the interface
188+
described by the
189+
`PackageMetadata protocol <https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.PackageMetadata>`.
190+
177191
.. versionchanged:: 3.10
178192
The ``Description`` is now included in the metadata when presented
179193
through the payload. Line continuation characters have been removed.
@@ -295,6 +309,15 @@ The full set of available metadata is not described here. See :pep:`566`
295309
for additional details.
296310

297311

312+
Distribution Discovery
313+
======================
314+
315+
By default, this package provides built-in support for discovery of metadata for file system and zip file packages. This metadata finder search defaults to ``sys.path``, but varies slightly in how it interprets those values from how other import machinery does. In particular:
316+
317+
- ``importlib.metadata`` does not honor :class:`bytes` objects on ``sys.path``.
318+
- ``importlib.metadata`` will incidentally honor :py:class:`pathlib.Path` objects on ``sys.path`` even though such values will be ignored for imports.
319+
320+
298321
Extending the search algorithm
299322
==============================
300323

Doc/library/locale.rst

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -412,18 +412,6 @@ The :mod:`locale` module defines the following exception and functions:
412412
The *monetary* keyword parameter was added.
413413

414414

415-
.. function:: format(format, val, grouping=False, monetary=False)
416-
417-
Please note that this function works like :meth:`format_string` but will
418-
only work for exactly one ``%char`` specifier. For example, ``'%f'`` and
419-
``'%.0f'`` are both valid specifiers, but ``'%f KiB'`` is not.
420-
421-
For whole format strings, use :func:`format_string`.
422-
423-
.. deprecated:: 3.7
424-
Use :meth:`format_string` instead.
425-
426-
427415
.. function:: currency(val, symbol=True, grouping=False, international=False)
428416

429417
Formats a number *val* according to the current :const:`LC_MONETARY` settings.
@@ -507,7 +495,7 @@ The :mod:`locale` module defines the following exception and functions:
507495

508496
.. data:: LC_NUMERIC
509497

510-
Locale category for formatting numbers. The functions :func:`.format`,
498+
Locale category for formatting numbers. The functions :func:`format_string`,
511499
:func:`atoi`, :func:`atof` and :func:`.str` of the :mod:`locale` module are
512500
affected by that category. All other numeric formatting operations are not
513501
affected.
@@ -569,7 +557,7 @@ document that your module is not compatible with non-\ ``C`` locale settings.
569557

570558
The only way to perform numeric operations according to the locale is to use the
571559
special functions defined by this module: :func:`atof`, :func:`atoi`,
572-
:func:`.format`, :func:`.str`.
560+
:func:`format_string`, :func:`.str`.
573561

574562
There is no way to perform case conversions and character classifications
575563
according to the locale. For (Unicode) text strings these are done according

Doc/library/unittest.rst

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,9 +1261,6 @@ Test cases
12611261
:meth:`.assertRegex`.
12621262
.. versionadded:: 3.2
12631263
:meth:`.assertNotRegex`.
1264-
.. versionadded:: 3.5
1265-
The name ``assertNotRegexpMatches`` is a deprecated alias
1266-
for :meth:`.assertNotRegex`.
12671264

12681265

12691266
.. method:: assertCountEqual(first, second, msg=None)
@@ -1660,40 +1657,6 @@ Test cases
16601657
:mod:`unittest`-based test framework.
16611658

16621659

1663-
.. _deprecated-aliases:
1664-
1665-
Deprecated aliases
1666-
##################
1667-
1668-
For historical reasons, some of the :class:`TestCase` methods had one or more
1669-
aliases that are now deprecated. The following table lists the correct names
1670-
along with their deprecated aliases:
1671-
1672-
============================== ====================== =======================
1673-
Method Name Deprecated alias Deprecated alias
1674-
============================== ====================== =======================
1675-
:meth:`.assertEqual` failUnlessEqual assertEquals
1676-
:meth:`.assertNotEqual` failIfEqual assertNotEquals
1677-
:meth:`.assertTrue` failUnless assert\_
1678-
:meth:`.assertFalse` failIf
1679-
:meth:`.assertRaises` failUnlessRaises
1680-
:meth:`.assertAlmostEqual` failUnlessAlmostEqual assertAlmostEquals
1681-
:meth:`.assertNotAlmostEqual` failIfAlmostEqual assertNotAlmostEquals
1682-
:meth:`.assertRegex` assertRegexpMatches
1683-
:meth:`.assertNotRegex` assertNotRegexpMatches
1684-
:meth:`.assertRaisesRegex` assertRaisesRegexp
1685-
============================== ====================== =======================
1686-
1687-
.. deprecated:: 3.1
1688-
The fail* aliases listed in the second column have been deprecated.
1689-
.. deprecated:: 3.2
1690-
The assert* aliases listed in the third column have been deprecated.
1691-
.. deprecated:: 3.2
1692-
``assertRegexpMatches`` and ``assertRaisesRegexp`` have been renamed to
1693-
:meth:`.assertRegex` and :meth:`.assertRaisesRegex`.
1694-
.. deprecated:: 3.5
1695-
The ``assertNotRegexpMatches`` name is deprecated in favor of :meth:`.assertNotRegex`.
1696-
16971660
.. _testsuite-objects:
16981661

16991662
Grouping tests
@@ -1819,7 +1782,7 @@ Loading and running tests
18191782
case is created for that method instead.
18201783

18211784

1822-
.. method:: loadTestsFromModule(module, pattern=None)
1785+
.. method:: loadTestsFromModule(module, *, pattern=None)
18231786

18241787
Return a suite of all test cases contained in the given module. This
18251788
method searches *module* for classes derived from :class:`TestCase` and
@@ -1843,10 +1806,11 @@ Loading and running tests
18431806
Support for ``load_tests`` added.
18441807

18451808
.. versionchanged:: 3.5
1846-
The undocumented and unofficial *use_load_tests* default argument is
1847-
deprecated and ignored, although it is still accepted for backward
1848-
compatibility. The method also now accepts a keyword-only argument
1849-
*pattern* which is passed to ``load_tests`` as the third argument.
1809+
Support for a keyword-only argument *pattern* has been added.
1810+
1811+
.. versionchanged:: 3.12
1812+
The undocumented and unofficial *use_load_tests* parameter has been
1813+
removed.
18501814

18511815

18521816
.. method:: loadTestsFromName(name, module=None)
@@ -2203,8 +2167,6 @@ Loading and running tests
22032167
:class:`TextTestRunner`.
22042168

22052169
.. versionadded:: 3.2
2206-
This class was previously named ``_TextTestResult``. The old name still
2207-
exists as an alias but is deprecated.
22082170

22092171

22102172
.. data:: defaultTestLoader
@@ -2227,10 +2189,7 @@ Loading and running tests
22272189
By default this runner shows :exc:`DeprecationWarning`,
22282190
:exc:`PendingDeprecationWarning`, :exc:`ResourceWarning` and
22292191
:exc:`ImportWarning` even if they are :ref:`ignored by default
2230-
<warning-ignored>`. Deprecation warnings caused by :ref:`deprecated unittest
2231-
methods <deprecated-aliases>` are also special-cased and, when the warning
2232-
filters are ``'default'`` or ``'always'``, they will appear only once
2233-
per-module, in order to avoid too many warning messages. This behavior can
2192+
<warning-ignored>`. This behavior can
22342193
be overridden using Python's :option:`!-Wd` or :option:`!-Wa` options
22352194
(see :ref:`Warning control <using-on-warnings>`) and leaving
22362195
*warnings* to ``None``.

0 commit comments

Comments
 (0)