Skip to content

Commit

Permalink
Merge branch 'main' into python#92240-whats-new
Browse files Browse the repository at this point in the history
  • Loading branch information
georgically committed May 19, 2022
2 parents 07963e2 + 70aa1b9 commit 587a857
Show file tree
Hide file tree
Showing 67 changed files with 890 additions and 801 deletions.
4 changes: 4 additions & 0 deletions Doc/library/asyncio-subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Constants
=========

.. data:: asyncio.subprocess.PIPE
:module:

Can be passed to the *stdin*, *stdout* or *stderr* parameters.

Expand All @@ -137,11 +138,13 @@ Constants
attributes will point to :class:`StreamReader` instances.

.. data:: asyncio.subprocess.STDOUT
:module:

Special value that can be used as the *stderr* argument and indicates
that standard error should be redirected into standard output.

.. data:: asyncio.subprocess.DEVNULL
:module:

Special value that can be used as the *stdin*, *stdout* or *stderr* argument
to process creation functions. It indicates that the special file
Expand All @@ -157,6 +160,7 @@ wrapper that allows communicating with subprocesses and watching for
their completion.

.. class:: asyncio.subprocess.Process
:module:

An object that wraps OS processes created by the
:func:`create_subprocess_exec` and :func:`create_subprocess_shell`
Expand Down
5 changes: 3 additions & 2 deletions Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,10 @@ Decimal objects
>>> Decimal(321).exp()
Decimal('2.561702493119680037517373933E+139')

.. method:: from_float(f)
.. classmethod:: from_float(f)

Classmethod that converts a float to a decimal number, exactly.
Alternative constructor that only accepts instances of :class:`float` or
:class:`int`.

Note `Decimal.from_float(0.1)` is not the same as `Decimal('0.1')`.
Since 0.1 is not exactly representable in binary floating point, the
Expand Down
17 changes: 3 additions & 14 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ the following command can be used to display the disassembly of
2 2 PUSH_NULL
4 LOAD_GLOBAL 1 (NULL + len)
6 LOAD_FAST 0 (alist)
8 PRECALL 1
10 CALL 1
12 RETURN_VALUE
8 CALL 1
18 RETURN_VALUE

(The "2" is a line number).

Expand Down Expand Up @@ -119,7 +118,6 @@ Example::
PUSH_NULL
LOAD_GLOBAL
LOAD_FAST
PRECALL
CALL
RETURN_VALUE

Expand Down Expand Up @@ -1182,15 +1180,6 @@ iterations of the loop.
.. versionadded:: 3.7


.. opcode:: PRECALL (argc)

Prefixes :opcode:`CALL`. Logically this is a no op.
It exists to enable effective specialization of calls.
``argc`` is the number of arguments as described in :opcode:`CALL`.

.. versionadded:: 3.11


.. opcode:: PUSH_NULL

Pushes a ``NULL`` to the stack.
Expand All @@ -1202,7 +1191,7 @@ iterations of the loop.

.. opcode:: KW_NAMES (i)

Prefixes :opcode:`PRECALL`.
Prefixes :opcode:`CALL`.
Stores a reference to ``co_consts[consti]`` into an internal variable
for use by :opcode:`CALL`. ``co_consts[consti]`` must be a tuple of strings.

Expand Down
48 changes: 21 additions & 27 deletions Doc/library/doctest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -563,41 +563,35 @@ doctest decides whether actual output matches an example's expected output:

.. data:: IGNORE_EXCEPTION_DETAIL

When specified, an example that expects an exception passes if an exception of
the expected type is raised, even if the exception detail does not match. For
example, an example expecting ``ValueError: 42`` will pass if the actual
exception raised is ``ValueError: 3*14``, but will fail, e.g., if
:exc:`TypeError` is raised.
When specified, doctests expecting exceptions pass so long as an exception
of the expected type is raised, even if the details
(message and fully-qualified exception name) don't match.

It will also ignore the module name used in Python 3 doctest reports. Hence
both of these variations will work with the flag specified, regardless of
whether the test is run under Python 2.7 or Python 3.2 (or later versions)::
For example, an example expecting ``ValueError: 42`` will pass if the actual
exception raised is ``ValueError: 3*14``, but will fail if, say, a
:exc:`TypeError` is raised instead.
It will also ignore any fully-qualified name included before the
exception class, which can vary between implementations and versions
of Python and the code/libraries in use.
Hence, all three of these variations will work with the flag specified:

>>> raise CustomError('message')
.. code-block:: pycon
>>> raise Exception('message')
Traceback (most recent call last):
CustomError: message
Exception: message
>>> raise CustomError('message')
>>> raise Exception('message')
Traceback (most recent call last):
my_module.CustomError: message
builtins.Exception: message
Note that :const:`ELLIPSIS` can also be used to ignore the
details of the exception message, but such a test may still fail based
on whether or not the module details are printed as part of the
exception name. Using :const:`IGNORE_EXCEPTION_DETAIL` and the details
from Python 2.3 is also the only clear way to write a doctest that doesn't
care about the exception detail yet continues to pass under Python 2.3 or
earlier (those releases do not support :ref:`doctest directives
<doctest-directives>` and ignore them as irrelevant comments). For example::

>>> (1, 2)[3] = 'moo'
>>> raise Exception('message')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object doesn't support item assignment
__main__.Exception: message
passes under Python 2.3 and later Python versions with the flag specified,
even though the detail
changed in Python 2.4 to say "does not" instead of "doesn't".
Note that :const:`ELLIPSIS` can also be used to ignore the
details of the exception message, but such a test may still fail based
on whether the module name is present or matches exactly.

.. versionchanged:: 3.2
:const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating
Expand Down
12 changes: 6 additions & 6 deletions Doc/library/fractions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ another rational number, or from a string.

.. versionadded:: 3.8

.. method:: from_float(flt)
.. classmethod:: from_float(flt)

This class method constructs a :class:`Fraction` representing the exact
value of *flt*, which must be a :class:`float`. Beware that
Alternative constructor which only accepts instances of
:class:`float` or :class:`numbers.Integral`. Beware that
``Fraction.from_float(0.3)`` is not the same value as ``Fraction(3, 10)``.

.. note::
Expand All @@ -126,10 +126,10 @@ another rational number, or from a string.
:class:`Fraction` instance directly from a :class:`float`.


.. method:: from_decimal(dec)
.. classmethod:: from_decimal(dec)

This class method constructs a :class:`Fraction` representing the exact
value of *dec*, which must be a :class:`decimal.Decimal` instance.
Alternative constructor which only accepts instances of
:class:`decimal.Decimal` or :class:`numbers.Integral`.

.. note::

Expand Down
6 changes: 3 additions & 3 deletions Doc/library/importlib.metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package metadata. Built in part on Python's import system, this library
intends to replace similar functionality in the `entry point
API`_ and `metadata API`_ of ``pkg_resources``. Along with
:mod:`importlib.resources` in Python 3.7
and newer (backported as `importlib_resources`_ for older versions of
Python), this can eliminate the need to use the older and less efficient
:mod:`importlib.resources` (with new features backported to the
`importlib_resources`_ package), this can eliminate the need to use the older
and less efficient
``pkg_resources`` package.

By "installed package" we generally mean a third-party package installed into
Expand Down
11 changes: 4 additions & 7 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ ABC hierarchy::

.. versionadded:: 3.4

.. versionchanged:: 3.5
Starting in Python 3.6, this method will not be optional when
.. versionchanged:: 3.6
This method is no longer optional when
:meth:`exec_module` is defined.

.. method:: exec_module(module)
Expand Down Expand Up @@ -1273,8 +1273,7 @@ import, then you should use :func:`importlib.util.find_spec`.
Importing a source file directly
''''''''''''''''''''''''''''''''

To import a Python source file directly, use the following recipe
(Python 3.5 and newer only)::
To import a Python source file directly, use the following recipe::

import importlib.util
import sys
Expand Down Expand Up @@ -1355,9 +1354,7 @@ Import itself is implemented in Python code, making it possible to
expose most of the import machinery through importlib. The following
helps illustrate the various APIs that importlib exposes by providing an
approximate implementation of
:func:`importlib.import_module` (Python 3.4 and newer for the importlib usage,
Python 3.6 and newer for other parts of the code).
::
:func:`importlib.import_module`::

import importlib.util
import sys
Expand Down
1 change: 1 addition & 0 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ different machines. A manager object controls a server process which manages
proxies.

.. function:: multiprocessing.Manager()
:module:

Returns a started :class:`~multiprocessing.managers.SyncManager` object which
can be used for sharing objects between processes. The returned manager
Expand Down
13 changes: 9 additions & 4 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3916,13 +3916,13 @@ written in Python, such as a mail server's external command delivery program.
.. availability:: Unix.


.. function:: popen(cmd, mode='r', buffering=-1, encoding=None)
.. function:: popen(cmd, mode='r', buffering=-1)

Open a pipe to or from command *cmd*.
The return value is an open file object
connected to the pipe, which can be read or written depending on whether *mode*
is ``'r'`` (default) or ``'w'``.
The *buffering* and *encoding* arguments have the same meaning as
The *buffering* argument have the same meaning as
the corresponding argument to the built-in :func:`open` function. The
returned file object reads or writes text strings rather than bytes.

Expand All @@ -3945,8 +3945,13 @@ written in Python, such as a mail server's external command delivery program.
documentation for more powerful ways to manage and communicate with
subprocesses.

.. versionchanged:: 3.11
Added the *encoding* parameter.
.. note::
The :ref:`Python UTF-8 Mode <utf8-mode>` affects encodings used
for *cmd* and pipe contents.

:func:`popen` is a simple wrapper around :class:`subprocess.Popen`.
Use :class:`subprocess.Popen` or :func:`subprocess.run` to
control options like encodings.


.. function:: posix_spawn(path, argv, env, *, file_actions=None, \
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ resolution and/or the host configuration. For deterministic behavior use a
numeric address in *host* portion.

All errors raise exceptions. The normal exceptions for invalid argument types
and out-of-memory conditions can be raised; starting from Python 3.3, errors
and out-of-memory conditions can be raised. Errors
related to socket or address semantics raise :exc:`OSError` or one of its
subclasses (they used to raise :exc:`socket.error`).
subclasses.

Non-blocking mode is supported through :meth:`~socket.setblocking`. A
generalization of this based on timeouts is supported through
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/ssl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ Constants
Selects SSL version 2 as the channel encryption protocol.

This protocol is not available if OpenSSL is compiled with the
``OPENSSL_NO_SSL2`` flag.
``no-ssl2`` option.

.. warning::

Expand All @@ -728,8 +728,8 @@ Constants

Selects SSL version 3 as the channel encryption protocol.

This protocol is not be available if OpenSSL is compiled with the
``OPENSSL_NO_SSLv3`` flag.
This protocol is not available if OpenSSL is compiled with the
``no-ssl3`` option.

.. warning::

Expand Down
3 changes: 0 additions & 3 deletions Doc/library/subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ The recommended approach to invoking subprocesses is to use the :func:`run`
function for all use cases it can handle. For more advanced use cases, the
underlying :class:`Popen` interface can be used directly.

The :func:`run` function was added in Python 3.5; if you need to retain
compatibility with older versions, see the :ref:`call-function-trio` section.


.. function:: run(args, *, stdin=None, input=None, stdout=None, stderr=None,\
capture_output=False, shell=False, cwd=None, timeout=None, \
Expand Down
2 changes: 2 additions & 0 deletions Doc/library/xml.etree.elementtree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ Functions
^^^^^^^^^

.. function:: xml.etree.ElementInclude.default_loader( href, parse, encoding=None)
:module:

Default loader. This default loader reads an included resource from disk. *href* is a URL.
*parse* is for parse mode either "xml" or "text". *encoding*
Expand All @@ -837,6 +838,7 @@ Functions

.. function:: xml.etree.ElementInclude.include( elem, loader=None, base_url=None, \
max_depth=6)
:module:

This function expands XInclude directives. *elem* is the root element. *loader* is
an optional resource loader. If omitted, it defaults to :func:`default_loader`.
Expand Down
4 changes: 2 additions & 2 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ precedence and have a left-to-right chaining feature as described in the
| ``x[index]``, ``x[index:index]``, | Subscription, slicing, |
| ``x(arguments...)``, ``x.attribute`` | call, attribute reference |
+-----------------------------------------------+-------------------------------------+
| :keyword:`await` ``x`` | Await expression |
| :keyword:`await x <await>` | Await expression |
+-----------------------------------------------+-------------------------------------+
| ``**`` | Exponentiation [#]_ |
+-----------------------------------------------+-------------------------------------+
Expand All @@ -1922,7 +1922,7 @@ precedence and have a left-to-right chaining feature as described in the
| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests |
| ``<=``, ``>``, ``>=``, ``!=``, ``==`` | |
+-----------------------------------------------+-------------------------------------+
| :keyword:`not` ``x`` | Boolean NOT |
| :keyword:`not x <not>` | Boolean NOT |
+-----------------------------------------------+-------------------------------------+
| :keyword:`and` | Boolean AND |
+-----------------------------------------------+-------------------------------------+
Expand Down
Loading

0 comments on commit 587a857

Please sign in to comment.