Skip to content

Commit

Permalink
Merge branch 'main' into typewatch
Browse files Browse the repository at this point in the history
* main:
  pythongh-86298: Ensure that __loader__ and __spec__.loader agree in warnings.warn_explicit() (pythonGH-97803)
  pythongh-82874: Convert remaining importlib format uses to f-str. (python#98005)
  Docs: Fix backtick errors found by sphinx-lint (python#97998)
  pythongh-97850: Remove deprecated functions from `importlib.utils` (python#97898)
  Remove extra spaces in custom openSSL documentation. (python#93568)
  pythonGH-90985: Revert  "Deprecate passing a message into cancel()" (python#97999)
  • Loading branch information
carljm committed Oct 7, 2022
2 parents 29e38df + 13d4489 commit 0de5aff
Show file tree
Hide file tree
Showing 75 changed files with 322 additions and 614 deletions.
2 changes: 1 addition & 1 deletion Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ is not possible due to its implementation being opaque at build time.
Free the given *key* allocated by :c:func:`PyThread_tss_alloc`, after
first calling :c:func:`PyThread_tss_delete` to ensure any associated
thread locals have been unassigned. This is a no-op if the *key*
argument is `NULL`.
argument is ``NULL``.
.. note::
A freed key becomes a dangling pointer. You should reset the key to
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Type Objects
.. c:function:: unsigned long PyType_GetFlags(PyTypeObject* type)
Return the :c:member:`~PyTypeObject.tp_flags` member of *type*. This function is primarily
meant for use with `Py_LIMITED_API`; the individual flag bits are
meant for use with ``Py_LIMITED_API``; the individual flag bits are
guaranteed to be stable across Python releases, but access to
:c:member:`~PyTypeObject.tp_flags` itself is not part of the limited API.
Expand Down
2 changes: 1 addition & 1 deletion Doc/faq/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Why can't I use an assignment in an expression?

Starting in Python 3.8, you can!

Assignment expressions using the walrus operator `:=` assign a variable in an
Assignment expressions using the walrus operator ``:=`` assign a variable in an
expression::

while chunk := fp.read(200):
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ Enum Classes
The :class:`EnumType` metaclass is responsible for providing the
:meth:`__contains__`, :meth:`__dir__`, :meth:`__iter__` and other methods that
allow one to do things with an :class:`Enum` class that fail on a typical
class, such as `list(Color)` or `some_enum_var in Color`. :class:`EnumType` is
class, such as ``list(Color)`` or ``some_enum_var in Color``. :class:`EnumType` is
responsible for ensuring that various other methods on the final :class:`Enum`
class are correct (such as :meth:`__new__`, :meth:`__getnewargs__`,
:meth:`__str__` and :meth:`__repr__`).
Expand Down
4 changes: 2 additions & 2 deletions Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ To run a logging listener in production, you may need to use a process-managemen
such as `Supervisor <http://supervisord.org/>`_. `Here
<https://gist.github.com/vsajip/4b227eeec43817465ca835ca66f75e2b>`_ is a Gist which
provides the bare-bones files to run the above functionality using Supervisor: you
will need to change the `/path/to/` parts in the Gist to reflect the actual paths you
will need to change the ``/path/to/`` parts in the Gist to reflect the actual paths you
want to use.


Expand Down Expand Up @@ -2774,7 +2774,7 @@ Formatting times using UTC (GMT) via configuration
--------------------------------------------------

Sometimes you want to format times using UTC, which can be done using a class
such as `UTCFormatter`, shown below::
such as ``UTCFormatter``, shown below::

import logging
import time
Expand Down
10 changes: 5 additions & 5 deletions Doc/howto/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,14 @@ raw message. If there is no date format string, the default date format is:
%Y-%m-%d %H:%M:%S
with the milliseconds tacked on at the end. The ``style`` is one of `%`, '{'
or '$'. If one of these is not specified, then '%' will be used.
with the milliseconds tacked on at the end. The ``style`` is one of ``'%'``,
``'{'``, or ``'$'``. If one of these is not specified, then ``'%'`` will be used.

If the ``style`` is '%', the message format string uses
If the ``style`` is ``'%'``, the message format string uses
``%(<dictionary key>)s`` styled string substitution; the possible keys are
documented in :ref:`logrecord-attributes`. If the style is '{', the message
documented in :ref:`logrecord-attributes`. If the style is ``'{'``, the message
format string is assumed to be compatible with :meth:`str.format` (using
keyword arguments), while if the style is '$' then the message format string
keyword arguments), while if the style is ``'$'`` then the message format string
should conform to what is expected by :meth:`string.Template.substitute`.

.. versionchanged:: 3.2
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/perf_profiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Enabling perf profiling mode
----------------------------

There are two main ways to activate the perf profiling mode. If you want it to be
active since the start of the Python interpreter, you can use the `-Xperf` option:
active since the start of the Python interpreter, you can use the ``-Xperf`` option:

$ python -Xperf my_script.py

Expand Down
2 changes: 1 addition & 1 deletion Doc/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ And on Windows, the configuration files are:
+--------------+-------------------------------------------------+-------+

On all platforms, the "personal" file can be temporarily disabled by
passing the `--no-user-cfg` option.
passing the ``--no-user-cfg`` option.

Notes:

Expand Down
10 changes: 0 additions & 10 deletions Doc/library/asyncio-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ Future Object
.. versionchanged:: 3.9
Added the *msg* parameter.

.. deprecated-removed:: 3.11 3.14
*msg* parameter is ambiguous when multiple :meth:`cancel`
are called with different cancellation messages.
The argument will be removed.

.. method:: exception()

Return the exception that was set on this Future.
Expand Down Expand Up @@ -282,8 +277,3 @@ the Future has a result::

- :meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument,
but :func:`concurrent.futures.cancel` does not.

.. deprecated-removed:: 3.11 3.14
*msg* parameter is ambiguous when multiple :meth:`cancel`
are called with different cancellation messages.
The argument will be removed.
2 changes: 1 addition & 1 deletion Doc/library/asyncio-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ accept factories that return streaming protocols.
a connection is open.

However, :meth:`protocol.eof_received() <Protocol.eof_received>`
is called at most once. Once `eof_received()` is called,
is called at most once. Once ``eof_received()`` is called,
``data_received()`` is not called anymore.

.. method:: Protocol.eof_received()
Expand Down
16 changes: 7 additions & 9 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ Timeouts

Change the time the timeout will trigger.

If *when* is `None`, any current deadline will be removed, and the
If *when* is ``None``, any current deadline will be removed, and the
context manager will wait indefinitely.

If *when* is a float, it is set as the new deadline.
Expand Down Expand Up @@ -867,17 +867,17 @@ Running in Threads
# blocking_io complete at 19:50:54
# finished main at 19:50:54

Directly calling `blocking_io()` in any coroutine would block the event loop
Directly calling ``blocking_io()`` in any coroutine would block the event loop
for its duration, resulting in an additional 1 second of run time. Instead,
by using `asyncio.to_thread()`, we can run it in a separate thread without
by using ``asyncio.to_thread()``, we can run it in a separate thread without
blocking the event loop.

.. note::

Due to the :term:`GIL`, `asyncio.to_thread()` can typically only be used
Due to the :term:`GIL`, ``asyncio.to_thread()`` can typically only be used
to make IO-bound functions non-blocking. However, for extension modules
that release the GIL or alternative Python implementations that don't
have one, `asyncio.to_thread()` can also be used for CPU-bound functions.
have one, ``asyncio.to_thread()`` can also be used for CPU-bound functions.

.. versionadded:: 3.9

Expand Down Expand Up @@ -1144,10 +1144,8 @@ Task Object
.. versionchanged:: 3.9
Added the *msg* parameter.

.. deprecated-removed:: 3.11 3.14
*msg* parameter is ambiguous when multiple :meth:`cancel`
are called with different cancellation messages.
The argument will be removed.
.. versionchanged:: 3.11
The ``msg`` parameter is propagated from cancelled task to its awaiter.

.. _asyncio_example_task_cancel:

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/bdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ The :mod:`bdb` module also defines two classes:

For real file names, the canonical form is an operating-system-dependent,
:func:`case-normalized <os.path.normcase>` :func:`absolute path
<os.path.abspath>`. A *filename* with angle brackets, such as `"<stdin>"`
<os.path.abspath>`. A *filename* with angle brackets, such as ``"<stdin>"``
generated in interactive mode, is returned unchanged.

.. method:: reset()
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/bz2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Incremental (de)compression
will be set to ``True``.

Attempting to decompress data after the end of stream is reached
raises an `EOFError`. Any data found after the end of the
raises an :exc:`EOFError`. Any data found after the end of the
stream is ignored and saved in the :attr:`~.unused_data` attribute.

.. versionchanged:: 3.5
Expand Down Expand Up @@ -303,7 +303,7 @@ Using :class:`BZ2Compressor` for incremental compression:
>>> out = out + comp.flush()

The example above uses a very "nonrandom" stream of data
(a stream of `b"z"` chunks). Random data tends to compress poorly,
(a stream of ``b"z"`` chunks). Random data tends to compress poorly,
while ordered, repetitive data usually yields a high compression ratio.

Writing and reading a bzip2-compressed file in binary mode:
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/concurrent.futures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ And::

All threads enqueued to ``ThreadPoolExecutor`` will be joined before the
interpreter can exit. Note that the exit handler which does this is
executed *before* any exit handlers added using `atexit`. This means
executed *before* any exit handlers added using ``atexit``. This means
exceptions in the main thread must be caught and handled in order to
signal threads to exit gracefully. For this reason, it is recommended
that ``ThreadPoolExecutor`` not be used for long-running tasks.
Expand Down Expand Up @@ -411,13 +411,13 @@ The :class:`Future` class encapsulates the asynchronous execution of a callable.
tests.

If the method returns ``False`` then the :class:`Future` was cancelled,
i.e. :meth:`Future.cancel` was called and returned `True`. Any threads
i.e. :meth:`Future.cancel` was called and returned ``True``. Any threads
waiting on the :class:`Future` completing (i.e. through
:func:`as_completed` or :func:`wait`) will be woken up.

If the method returns ``True`` then the :class:`Future` was not cancelled
and has been put in the running state, i.e. calls to
:meth:`Future.running` will return `True`.
:meth:`Future.running` will return ``True``.

This method can only be called once and cannot be called after
:meth:`Future.set_result` or :meth:`Future.set_exception` have been
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ Utility functions
.. function:: GetLastError()

Windows only: Returns the last error code set by Windows in the calling thread.
This function calls the Windows `GetLastError()` function directly,
This function calls the Windows ``GetLastError()`` function directly,
it does not return the ctypes-private copy of the error code.

.. function:: get_errno()
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ The module :mod:`curses` defines the following functions:
Change the definition of a color, taking the number of the color to be changed
followed by three RGB values (for the amounts of red, green, and blue
components). The value of *color_number* must be between ``0`` and
`COLORS - 1`. Each of *r*, *g*, *b*, must be a value between ``0`` and
``COLORS - 1``. Each of *r*, *g*, *b*, must be a value between ``0`` and
``1000``. When :func:`init_color` is used, all occurrences of that color on the
screen immediately change to the new definition. This function is a no-op on
most terminals; it is active only if :func:`can_change_color` returns ``True``.
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ Other constructor:
ISO 8601 format, with the following exceptions:

1. Time zone offsets may have fractional seconds.
2. The leading `T`, normally required in cases where there may be ambiguity between
2. The leading ``T``, normally required in cases where there may be ambiguity between
a date and a time, is not required.
3. Fractional seconds may have any number of digits (anything beyond 6 will
be truncated).
Expand Down Expand Up @@ -2265,7 +2265,7 @@ where historical changes have been made to civil time.
two digits of ``offset.hours`` and ``offset.minutes`` respectively.

.. versionchanged:: 3.6
Name generated from ``offset=timedelta(0)`` is now plain `'UTC'`, not
Name generated from ``offset=timedelta(0)`` is now plain ``'UTC'``, not
``'UTC+00:00'``.


Expand Down
8 changes: 4 additions & 4 deletions Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,11 @@ Decimal objects
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')`.
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
value is stored as the nearest representable value which is
`0x1.999999999999ap-4`. That equivalent value in decimal is
`0.1000000000000000055511151231257827021181583404541015625`.
``0x1.999999999999ap-4``. That equivalent value in decimal is
``0.1000000000000000055511151231257827021181583404541015625``.

.. note:: From Python 3.2 onwards, a :class:`Decimal` instance
can also be constructed directly from a :class:`float`.
Expand Down Expand Up @@ -1209,7 +1209,7 @@ In addition to the three supplied contexts, new contexts can be created with the

.. method:: exp(x)

Returns `e ** x`.
Returns ``e ** x``.


.. method:: fma(x, y, z)
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ details of bytecode instructions as :class:`Instruction` instances:

.. class:: Positions

In case the information is not available, some fields might be `None`.
In case the information is not available, some fields might be ``None``.

.. data:: lineno
.. data:: end_lineno
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/email.compat32-message.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Here are the methods of the :class:`Message` class:
In a model generated from bytes, any header values that (in contravention of
the RFCs) contain non-ASCII bytes will, when retrieved through this
interface, be represented as :class:`~email.header.Header` objects with
a charset of `unknown-8bit`.
a charset of ``unknown-8bit``.


.. method:: __len__()
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/email.headerregistry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ headers.
specified as ``-0000`` (indicating it is in UTC but contains no
information about the source timezone), then :attr:`.datetime` will be a
naive :class:`~datetime.datetime`. If a specific timezone offset is
found (including `+0000`), then :attr:`.datetime` will contain an aware
found (including ``+0000``), then :attr:`.datetime` will contain an aware
``datetime`` that uses :class:`datetime.timezone` to record the timezone
offset.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/fractions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ another rational number, or from a string.
``typing.SupportsInt`` instance checks.

.. versionchanged:: 3.12
Space is allowed around the slash for string inputs: `Fraction('2 / 3')`.
Space is allowed around the slash for string inputs: ``Fraction('2 / 3')``.

.. attribute:: numerator

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/hashlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ Constructor functions also accept the following tree hashing parameters:
BLAKE2s, 0 in sequential mode).

* *last_node*: boolean indicating whether the processed node is the last
one (`False` for sequential mode).
one (``False`` for sequential mode).

.. figure:: hashlib-blake2-tree.png
:alt: Explanation of tree mode parameters.
Expand Down
54 changes: 1 addition & 53 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ ABC hierarchy::
from the import. If the loader inserted a module and the load fails, it
must be removed by the loader from :data:`sys.modules`; modules already
in :data:`sys.modules` before the loader began execution should be left
alone (see :func:`importlib.util.module_for_loader`).
alone.

The loader should set several attributes on the module
(note that some of these attributes can change when a module is
Expand Down Expand Up @@ -1326,58 +1326,6 @@ an :term:`importer`.

.. versionadded:: 3.5

.. decorator:: module_for_loader

A :term:`decorator` for :meth:`importlib.abc.Loader.load_module`
to handle selecting the proper
module object to load with. The decorated method is expected to have a call
signature taking two positional arguments
(e.g. ``load_module(self, module)``) for which the second argument
will be the module **object** to be used by the loader.
Note that the decorator will not work on static methods because of the
assumption of two arguments.

The decorated method will take in the **name** of the module to be loaded
as expected for a :term:`loader`. If the module is not found in
:data:`sys.modules` then a new one is constructed. Regardless of where the
module came from, :attr:`__loader__` set to **self** and :attr:`__package__`
is set based on what :meth:`importlib.abc.InspectLoader.is_package` returns
(if available). These attributes are set unconditionally to support
reloading.

If an exception is raised by the decorated method and a module was added to
:data:`sys.modules`, then the module will be removed to prevent a partially
initialized module from being in left in :data:`sys.modules`. If the module
was already in :data:`sys.modules` then it is left alone.

.. versionchanged:: 3.3
:attr:`__loader__` and :attr:`__package__` are automatically set
(when possible).

.. versionchanged:: 3.4
Set :attr:`__name__`, :attr:`__loader__` :attr:`__package__`
unconditionally to support reloading.

.. deprecated:: 3.4
The import machinery now directly performs all the functionality
provided by this function.

.. decorator:: set_loader

A :term:`decorator` for :meth:`importlib.abc.Loader.load_module`
to set the :attr:`__loader__`
attribute on the returned module. If the attribute is already set the
decorator does nothing. It is assumed that the first positional argument to
the wrapped method (i.e. ``self``) is what :attr:`__loader__` should be set
to.

.. versionchanged:: 3.4
Set ``__loader__`` if set to ``None``, as if the attribute does not
exist.

.. deprecated:: 3.4
The import machinery takes care of this automatically.

.. function:: spec_from_loader(name, loader, *, origin=None, is_package=None)

A factory function for creating a :class:`~importlib.machinery.ModuleSpec`
Expand Down
Loading

0 comments on commit 0de5aff

Please sign in to comment.