10000 Merge remote-tracking branch 'upstream/main' into sha2_hacl · python/cpython@227e5b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 227e5b0

Browse files
committed
Merge remote-tracking branch 'upstream/main' into sha2_hacl
2 parents c670530 + aacbdb0 commit 227e5b0

File tree

182 files changed

+7771
-5825
lines changed
  • faq
  • howto
  • library
  • tutorial
  • using
  • whatsnew
  • Include
  • Lib
  • Misc
  • Modules
  • Objects
  • PC
  • PCbuild
  • Programs
  • Python
  • Tools
  • Some content is hidden

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

    182 files changed

    +7771
    -5825
    lines changed

    Doc/Makefile

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -9,6 +9,7 @@ VENVDIR = ./venv
    99
    SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
    1010
    SPHINXLINT = PATH=$(VENVDIR)/bin:$$PATH sphinx-lint
    1111
    BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
    12+
    JOBS = auto
    1213
    PAPER =
    1314
    SOURCES =
    1415
    DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
    @@ -18,7 +19,7 @@ SPHINXERRORHANDLING = -W
    1819
    PAPEROPT_a4 = -D latex_elements.papersize=a4paper
    1920
    PAPEROPT_letter = -D latex_elements.papersize=letterpaper
    2021

    21-
    ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j auto \
    22+
    ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j $(JOBS) \
    2223
    $(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
    2324

    2425
    .PHONY: help

    Doc/bugs.rst

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -19,6 +19,9 @@ If you find a bug in this documentation or would like to propose an improvement,
    1919
    please submit a bug report on the :ref:`tracker <using-the-tracker>`. If you
    2020
    have a suggestion on how to fix it, include that as well.
    2121

    22+
    You can also open a discussion item on our
    23+
    `Documentation Discourse forum <https://discuss.python.org/c/documentation/26>`_.
    24+
    2225
    If you're short on time, you can also email documentation bug reports to
    2326
    docs@python.org (behavioral bugs can be sent to python-list@python.org).
    2427
    'docs@' is a mailing list run by volunteers; your request will be noticed,

    Doc/c-api/code.rst

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -77,6 +77,8 @@ bound into a function.
    7777
    7878
    Returns ``1`` if the function succeeds and 0 otherwise.
    7979
    80+
    .. versionadded:: 3.11
    81+
    8082
    .. c:function:: PyObject* PyCode_GetCode(PyCodeObject *co)
    8183
    8284
    Equivalent to the Python code ``getattr(co, 'co_code')``.

    Doc/faq/general.rst

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -248,8 +248,8 @@ Are there any published articles about Python that I can reference?
    248248

    249249
    It's probably best to cite your favorite book about Python.
    250250

    251-
    The very first article about Python was written in 1991 and is now quite
    252-
    outdated.
    251+
    The `very first article <https://ir.cwi.nl/pub/18204>`_ about Python was
    252+
    written in 1991 and is now quite outdated.
    253253

    254254
    Guido van Rossum and Jelke de Boer, "Interactively Testing Remote Servers
    255255
    Using the Python Programming Language", CWI Quarterly, Volume 4, Issue 4

    Doc/howto/logging-cookbook.rst

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -307,7 +307,7 @@ Suppose you configure logging with the following JSON:
    307307
    "class": "logging.StreamHandler",
    308308
    "level": "INFO",
    309309
    "formatter": "simple",
    310-
    "stream": "ext://sys.stdout",
    310+
    "stream": "ext://sys.stdout"
    311311
    },
    312312
    "stderr": {
    313313
    "class": "logging.StreamHandler",

    Doc/library/argparse.rst

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -31,7 +31,7 @@ Core Functionality
    3131

    3232
    The :mod:`argparse` module's support for command-line interfaces is built
    3333
    around an instance of :class:`argparse.ArgumentParser`. It is a container for
    34-
    argument specifications and has options that apply the parser as whole::
    34+
    argument specifications and has options that apply to the parser as whole::
    3535

    3636
    parser = argparse.ArgumentParser(
    3737
    prog = 'ProgramName',

    Doc/library/array.rst

    Lines changed: 89 additions & 90 deletions
    Original file line numberDiff line numberDiff line change
    @@ -60,7 +60,7 @@ Notes:
    6060

    6161
    The actual representation of values is determined by the machine architecture
    6262
    (strictly speaking, by the C implementation). The actual size can be accessed
    63-
    through the :attr:`itemsize` attribute.
    63+
    through the :attr:`array.itemsize` attribute.
    6464

    6565
    The module defines the following item:
    6666

    @@ -85,161 +85,160 @@ The module defines the following type:
    8585
    to add initial items to the array. Otherwise, the iterable initializer is
    8686
    passed to the :meth:`extend` method.
    8787

    88-
    .. audit-event:: array.__new__ typecode,initializer array.array
    88+
    Array objects support the ordinary sequence operations of indexing, slicing,
    89+
    concatenation, and multiplication. When using slice assignment, the assigned
    90+
    value must be an array object with the same type code; in all other cases,
    91+
    :exc:`TypeError` is raised. Array objects also implement the buffer interface,
    92+
    and may be used wherever :term:`bytes-like objects <bytes-like object>` are supported.
    8993

    94+
    .. audit-event:: array.__new__ typecode,initializer array.array
    9095

    91-
    Array objects support the ordinary sequence operations of indexing, slicing,
    92-
    concatenation, and multiplication. When using slice assignment, the assigned
    93-
    value must be an array object with the same type code; in all other cases,
    94-
    :exc:`TypeError` is raised. Array objects also implement the buffer interface,
    95-
    and may be used wherever :term:`bytes-like objects <bytes-like object>` are supported.
    9696

    97-
    The following data items and methods are also supported:
    97+
    .. attribute:: typecode
    9898

    99-
    .. attribute:: array.typecode
    99+
    The typecode character used to create the array.
    100100

    101-
    The typecode character used to create the array.
    102101

    102+
    .. attribute:: itemsize
    103103

    104-
    .. attribute:: array.itemsize
    104+
    The length in bytes of one array item in the internal representation.
    105105

    106-
    The length in bytes of one array item in the internal representation.
    107106

    107+
    .. method:: append(x)
    108108

    109-
    .. method:: array.append(x)
    109+
    Append a new item with value *x* to the end of the array.
    110110

    111-
    Append a new item with value *x* to the end of the array.
    112111

    112+
    .. method:: buffer_info()
    113113

    114-
    .. method:: array.buffer_info()
    114+
    Return a tuple ``(address, length)`` giving the current memory address and the
    115+
    length in elements of the buffer used to hold array's contents. The size of the
    116+
    memory buffer in bytes can be computed as ``array.buffer_info()[1] *
    117+
    array.itemsize``. This is occasionally useful when working with low-level (and
    118+
    inherently unsafe) I/O interfaces that require memory addresses, such as certain
    119+
    :c:func:`!ioctl` operations. The returned numbers are valid as long as the array
    120+
    exists and no length-changing operations are applied to it.
    115121

    116-
    Return a tuple ``(address, length)`` giving the current memory address and the
    117-
    length in elements of the buffer used to hold array's contents. The size of the
    118-
    memory buffer in bytes can be computed as ``array.buffer_info()[1] *
    119-
    array.itemsize``. This is occasionally useful when working with low-level (and
    120-
    inherently unsafe) I/O interfaces that require memory addresses, such as certain
    121-
    :c:func:`ioctl` operations. The returned numbers are valid as long as the array
    122-
    exists and no length-changing operations are applied to it.
    122+
    .. note::
    123123

    124-
    .. note::
    124+
    When using array objects from code written in C or C++ (the only way to
    125+
    effectively make use of this information), it makes more sense to use the buffer
    126+
    interface supported by array objects. This method is maintained for backward
    127+
    compatibility and should be avoided in new code. The buffer interface is
    128+
    documented in :ref:`bufferobjects`.
    125129

    126-
    When using array objects from code written in C or C++ (the only way to
    127-
    effectively make use of this information), it makes more sense to use the buffer
    128-
    interface supported by array objects. This method is maintained for backward
    129-
    compatibility and should be avoided in new code. The buffer interface is
    130-
    documented in :ref:`bufferobjects`.
    131130

    131+
    .. method:: byteswap()
    132132

    133-
    .. method:: array.byteswap()
    133+
    "Byteswap" all items of the array. This is only supported for values which are
    134+
    1, 2, 4, or 8 bytes in size; for other types of values, :exc:`RuntimeError` is
    135+
    raised. It is useful when reading data from a file written on a machine with a
    136+
    different byte order.
    134137

    135-
    "Byteswap" all items of the array. This is only supported for values which are
    136-
    1, 2, 4, or 8 bytes in size; for other types of values, :exc:`RuntimeError` is
    137-
    raised. It is useful when reading data from a file written on a machine with a
    138-
    different byte order.
    139138

    139+
    .. method:: count(x)
    140140

    141-
    .. method:: array.count(x)
    141+
    Return the number of occurrences of *x* in the array.
    142142

    143-
    Return the number of occurrences of *x* in the array.
    144143

    144+
    .. method:: extend(iterable)
    145145

    146-
    .. method:: array.extend(iterable)
    146+
    Append items from *iterable* to the end of the array. If *iterable* is another
    147+
    array, it must have *exactly* the same type code; if not, :exc:`TypeError` will
    148+
    be raised. If *iterable* is not an array, it must be iterable and its elements
    149+
    must be the right type to be appended to the array.
    147150

    148-
    Append items from *iterable* to the end of the array. If *iterable* is another
    149-
    array, it must have *exactly* the same type code; if not, :exc:`TypeError` will
    150-
    be raised. If *iterable* is not an array, it must be iterable and its elements
    151-
    must be the right type to be appended to the array.
    152151

    152+
    .. method:: frombytes(s)
    153153

    154-
    .. method:: array.frombytes(s)
    154+
    Appends items from the string, interpreting the string as an array of machine
    155+
    values (as if it had been read from a file using the :meth:`fromfile` method).
    155156

    156-
    Appends items from the string, interpreting the string as an array of machine
    157-
    values (as if it had been read from a file using the :meth:`fromfile` method).
    157+
    .. versionadded:: 3.2
    158+
    :meth:`!fromstring` is renamed to :meth:`frombytes` for clarity.
    158159

    159-
    .. versionadded:: 3.2
    160-
    :meth:`fromstring` is renamed to :meth:`frombytes` for clarity.
    161160

    161+
    .. method:: fromfile(f, n)
    162162

    163-
    .. method:: array.fromfile(f, n)
    163+
    Read *n* items (as machine values) from the :term:`file object` *f* and append
    164+
    them to the end of the array. If less than *n* items are available,
    165+
    :exc:`EOFError` is raised, but the items that were available are still
    166+
    inserted into the array.
    164167

    165-
    Read *n* items (as machine values) from the :term:`file object` *f* and append
    166-
    them to the end of the array. If less than *n* items are available,
    167-
    :exc:`EOFError` is raised, but the items that were available are still
    168-
    inserted into the array.
    169168

    169+
    .. method:: fromlist(list)
    170170

    171-
    .. method:: array.fromlist(list)
    171+
    Append items from the list. This is equivalent to ``for x in list:
    172+
    a.append(x)`` except that if there is a type error, the array is unchanged.
    172173

    173-
    Append items from the list. This is equivalent to ``for x in list:
    174-
    a.append(x)`` except that if there is a type error, the array is unchanged.
    175174

    175+
    .. method:: fromunicode(s)
    176176

    177-
    .. method:: array.fromunicode(s)
    177+
    Extends this array with data from the given unicode string. The array must
    178+
    be a type ``'u'`` array; otherwise a :exc:`ValueError` is raised. Use
    179+
    ``array.frombytes(unicodestring.encode(enc))`` to append Unicode data to an
    180+
    array of some other type.
    178181

    179-
    Extends this array with data from the given unicode string. The array must
    180-
    be a type ``'u'`` array; otherwise a :exc:`ValueError` is raised. Use
    181-
    ``array.frombytes(unicodestring.encode(enc))`` to append Unicode data to an
    182-
    array of some other type.
    183182

    183+
    .. method:: index(x[, start[, stop]])
    184184

    185-
    .. method:: array.index(x[, start[, stop]])
    185+
    Return the smallest *i* such that *i* is the index of the first occurrence of
    186+
    *x* in the array. The optional arguments *start* and *stop* can be
    187+
    specified to search for *x* within a subsection of the array. Raise
    188+
    :exc:`ValueError` if *x* is not found.
    186189

    187-
    Return the smallest *i* such that *i* is the index of the first occurrence of
    188-
    *x* in the array. The optional arguments *start* and *stop* can be
    189-
    specified to search for *x* within a subsection of the array. Raise
    190-
    :exc:`ValueError` if *x* is not found.
    190+
    .. versionchanged:: 3.10
    191+
    Added optional *start* and *stop* parameters.
    191192

    192-
    .. versionchanged:: 3.10
    193-
    Added optional *start* and *stop* parameters.
    194193

    195-
    .. method:: array.insert(i, x)
    194+
    .. method:: insert(i, x)
    196195

    197-
    Insert a new item with value *x* in the array before position *i*. Negative
    198-
    values are treated as being relative to the end of the array.
    196+
    Insert a new item with value *x* in the array before position *i*. Negative
    197+
    values are treated as being relative to the end of the array.
    199198

    200199

    201-
    .. method:: array.pop([i])
    200+
    .. method:: pop([i])
    202201

    203-
    Removes the item with the index *i* from the array and returns it. The optional
    204-
    argument defaults to ``-1``, so that by default the last item is removed and
    205-
    returned.
    202+
    Removes the item with the index *i* from the array and returns it. The optional
    203+
    argument defaults to ``-1``, so that by default the last item is removed and
    204+
    returned.
    206205

    207206

    208-
    .. method:: array.remove(x)
    207+
    .. method:: remove(x)
    209208

    210-
    Remove the first occurrence of *x* from the array.
    209+
    Remove the first occurrence of *x* from the array.
    211210

    212211

    213-
    .. method:: array.reverse()
    212+
    .. method:: reverse()
    214213

    215-
    Reverse the order of the items in the array.
    214+
    Reverse the order of the items in the array.
    216215

    217216

    218-
    .. method:: array.tobytes()
    217+
    .. method:: tobytes()
    219218

    220-
    Convert the array to an array of machine values and return the bytes
    221-
    representation (the same sequence of bytes that would be written to a file by
    222-
    the :meth:`tofile` method.)
    219+
    Convert the array to an array of machine values and return the bytes
    220+
    representation (the same sequence of bytes that would be written to a file by
    221+
    the :meth:`tofile` method.)
    223222

    224-
    .. versionadded:: 3.2
    225-
    :meth:`tostring` is renamed to :meth:`tobytes` for clarity.
    223+
    .. versionadded:: 3.2
    224+
    :meth:`!tostring` is renamed to :meth:`tobytes` for clarity.
    226225

    227226

    228-
    .. method:: array.tofile(f)
    227+
    .. method:: tofile(f)
    229228

    230-
    Write all items (as machine values) to the :term:`file object` *f*.
    229+
    Write all items (as machine values) to the :term:`file object` *f*.
    231230

    232231

    233-
    .. method:: array.tolist()
    232+
    .. method:: tolist()
    234233

    235-
    Convert the array to an ordinary list with the same items.
    234+
    Convert the array to an ordinary list with the same items.
    236235

    237236

    238-
    .. method:: array.tounicode()
    237+
    .. method:: tounicode()
    239238

    240-
    Convert the array to a unicode string. The array must be a type ``'u'`` array;
    241-
    otherwise a :exc:`ValueError` is raised. Use ``array.tobytes().decode(enc)`` to
    242-
    obtain a unicode string from an array of some other type.
    239+
    Convert the array to a unicode string. The array must be a type ``'u'`` array;
    240+
    otherwise a :exc:`ValueError` is raised. Use ``array.tobytes().decode(enc)`` to
    241+
    obtain a unicode string from an array of some other type.
    243242

    244243

    245244
    When an array object is printed or converted to a string, it is represented as

    Doc/library/asyncio-eventloop.rst

    Lines changed: 24 additions & 18 deletions
    Original file line numberDiff line numberDiff line change
    @@ -186,19 +186,24 @@ Running and stopping the loop
    186186
    .. coroutinemethod:: loop.shutdown_default_executor(timeout=None)
    187187

    188188
    Schedule the closure of the default executor and wait for it to join all of
    189-
    the threads in the :class:`ThreadPoolExecutor`. After calling this method, a
    190-
    :exc:`RuntimeError` will be raised if :meth:`loop.run_in_executor` is called
    191-
    while using the default executor.
    189+
    the threads in the :class:`~concurrent.futures.ThreadPoolExecutor`.
    190+
    Once this method has been called,
    191+
    using the default executor with :meth:`loop.run_in_executor`
    192+
    will raise a :exc:`RuntimeError`.
    192193

    193-
    The *timeout* parameter specifies the amount of time the executor will
    194-
    be given to finish joining. The default value is ``None``, which means the
    195-
    executor will be given an unlimited amount of time.
    194+
    The *timeout* parameter specifies the amount of time
    195+
    (in :class:`float` seconds) the executor will be given to finish joining.
    196+
    With the default, ``None``,
    197+
    the executor is allowed an unlimited amount of time.
    196198

    197-
    If the timeout duration is reached, a warning is emitted and executor is
    198-
    terminated without waiting for its threads to finish joining.
    199+
    If the *timeout* is reached, a :exc:`RuntimeWarning` is emitted
    200+
    and the default executor is terminated
    201+
    without waiting for its threads to finish joining.
    199202

    200-
    Note that there is no need to call this function when
    201-
    :func:`asyncio.run` is used.
    203+
    .. note::
    204+
    205+
    Do not call this method when using :func:`asyncio.run`,
    206+
    as the latter handles default executor shutdown automatically.
    202207

    203208
    .. versionadded:: 3.9
    204209

    @@ -213,22 +218,23 @@ Scheduling callbacks
    213218
    Schedule the *callback* :term:`callback` to be called with
    214219
    *args* arguments at the next iteration of the event loop.
    215220

    221+
    Return an instance of :class:`asyncio.Handle`,
    222+
    which can be used later to cancel the callback.
    223+
    216224
    Callbacks are called in the order in which they are registered.
    217225
    Each callback will be called exactly once.
    218226

    219-
    An optional keyword-only *context* argument allows specifying a
    227+
    The optional keyword-only *context* argument specifies a
    220228
    custom :class:`contextvars.Context` for the *callback* to run in.
    221-
    The current context is used when no *context* is provided.
    222-
    223-
    An instance of :class:`asyncio.Handle` is returned, which can be
    224-
    used later to cancel the callback.
    229+
    Callbacks use the current context when no *context* is provided.
    225230

    226-
    This method is not thread-safe.
    231+
    Unlike :meth:`call_soon_threadsafe`, this method is not thread-safe.
    227232

    228233
    .. method:: loop.call_soon_threadsafe(callback, *args, context=None)
    229234

    230-
    A thread-safe variant of :meth:`call_soon`. Must be used to
    231-
    schedule callbacks *from another thread*.
    235+
    A thread-safe variant of :meth:`call_soon`. When scheduling callbacks from
    236+
    another thread, this function *must* be used, since :meth:`call_soon` is not
    237+
    thread-safe.
    232238

    233239
    Raises :exc:`RuntimeError` if called on a loop that's been closed.
    234240
    This can happen on a secondary thread when the main application is

    0 commit comments

    Comments
     (0)
    0