Skip to content

Commit 306f132

Browse files
committed
Merge branch 'main' into writer_resize2
2 parents 2f1e965 + d9565e5 commit 306f132

96 files changed

Lines changed: 2161 additions & 371 deletions

File tree

Some content is hidden

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

Doc/c-api/complex.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,6 @@ the :ref:`Number Protocol <number>` API or use native complex types, like
197197
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
198198
199199
.. deprecated:: 3.15
200+
201+
.. versionchanged:: next
202+
This function leaves :c:data:`errno` unchanged on success.

Doc/c-api/typeobj.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,9 +1869,10 @@ and :c:data:`PyType_Type` effectively act as defaults.)
18691869

18701870
PyObject *tp_iternext(PyObject *self);
18711871

1872-
When the iterator is exhausted, it must return ``NULL``; a :exc:`StopIteration`
1873-
exception may or may not be set. When another error occurs, it must return
1874-
``NULL`` too. Its presence signals that the instances of this type are
1872+
When the iterator is :term:`exhausted`, the ``tp_iternext`` function must
1873+
return ``NULL``; a :exc:`StopIteration` exception may or may not be set.
1874+
When another error occurs, it must return ``NULL`` too.
1875+
The presence of ``tp_iternext`` signals that the instances of this type are
18751876
iterators.
18761877

18771878
Iterator types should also define the :c:member:`~PyTypeObject.tp_iter` function, and that

Doc/glossary.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,14 @@ Glossary
505505
of an object, such as the value of type aliases created with the :keyword:`type`
506506
statement.
507507

508+
exhausted
509+
An :term:`iterator` that has produced all of its values is said to be
510+
:dfn:`exhausted`.
511+
Further attempts to get the next value (for example, calls to
512+
:func:`next`) raise :exc:`StopIteration`
513+
(or :exc:`StopAsyncIteration` in the case of an :term:`asynchronous
514+
iterator`).
515+
508516
expression
509517
A piece of syntax which can be evaluated to some value. In other words,
510518
an expression is an accumulation of expression elements like literals,
@@ -869,7 +877,7 @@ Glossary
869877
:meth:`~iterator.__next__` method (or passing it to the built-in function
870878
:func:`next`) return successive items in the stream. When no more data
871879
are available a :exc:`StopIteration` exception is raised instead. At this
872-
point, the iterator object is exhausted and any further calls to its
880+
point, the iterator object is :term:`exhausted` and any further calls to its
873881
:meth:`!__next__` method just raise :exc:`StopIteration` again. Iterators
874882
are required to have an :meth:`~iterator.__iter__` method that returns the iterator
875883
object itself so every iterator is also iterable and may be used in most

Doc/howto/functional.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,10 @@ returns them in a tuple::
720720
zip(['a', 'b', 'c'], (1, 2, 3)) =>
721721
('a', 1), ('b', 2), ('c', 3)
722722

723-
It doesn't construct an in-memory list and exhaust all the input iterators
724-
before returning; instead tuples are constructed and returned only if they're
725-
requested. (The technical term for this behaviour is `lazy evaluation
723+
It doesn't construct an in-memory list and :term:`exhaust <exhausted>` all
724+
the input iterators before returning; instead tuples are constructed and
725+
returned only if they're requested.
726+
(The technical term for this behaviour is `lazy evaluation
726727
<https://en.wikipedia.org/wiki/Lazy_evaluation>`__.)
727728

728729
This iterator is intended to be used with iterables that are all of the same
@@ -783,7 +784,7 @@ element *n* times, or returns the element endlessly if *n* is not provided. ::
783784
:func:`itertools.chain(iterA, iterB, ...) <itertools.chain>` takes an arbitrary
784785
number of iterables as input, and returns all the elements of the first
785786
iterator, then all the elements of the second, and so on, until all of the
786-
iterables have been exhausted. ::
787+
iterables have been :term:`exhausted`. ::
787788

788789
itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>
789790
a, b, c, 1, 2, 3
@@ -878,7 +879,7 @@ iterable's results. ::
878879

879880
:func:`itertools.compress(data, selectors) <itertools.compress>` takes two
880881
iterators and returns only those elements of *data* for which the corresponding
881-
element of *selectors* is true, stopping whenever either one is exhausted::
882+
element of *selectors* is true, stopping whenever either one is :term:`exhausted`::
882883

883884
itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>
884885
1, 2, 5
@@ -1028,7 +1029,7 @@ that takes two elements and returns a single value. :func:`functools.reduce`
10281029
takes the first two elements A and B returned by the iterator and calculates
10291030
``func(A, B)``. It then requests the third element, C, calculates
10301031
``func(func(A, B), C)``, combines this result with the fourth element returned,
1031-
and continues until the iterable is exhausted. If the iterable returns no
1032+
and continues until the iterable is :term:`exhausted`. If the iterable returns no
10321033
values at all, a :exc:`TypeError` exception is raised. If the initial value is
10331034
supplied, it's used as a starting point and ``func(initial_value, A)`` is the
10341035
first calculation. ::

Doc/library/collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ added elements by appending to the right and popping to the left::
699699
A `round-robin scheduler
700700
<https://en.wikipedia.org/wiki/Round-robin_scheduling>`_ can be implemented with
701701
input iterators stored in a :class:`deque`. Values are yielded from the active
702-
iterator in position zero. If that iterator is exhausted, it can be removed
702+
iterator in position zero. If that iterator is :term:`exhausted`, it can be removed
703703
with :meth:`~deque.popleft`; otherwise, it can be cycled back to the end with
704704
the :meth:`~deque.rotate` method::
705705

Doc/library/colorsys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spaces, the coordinates are all between 0 and 1.
1919
.. seealso::
2020

2121
More information about color spaces can be found at
22-
https://poynton.ca/ColorFAQ.html and
22+
https://www.poynton.ca/pdf/ColourFAQ.pdf and
2323
https://www.cambridgeincolour.com/tutorials/color-spaces.htm.
2424

2525
The :mod:`!colorsys` module defines the following functions:

Doc/library/ctypes.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ Specifying function pointers using type annotations
708708

709709
@wrap_dll_function(dll_to_wrap)
710710
def function_ptr_name(arg_name: ctypes_type, ...) -> ctypes_type:
711-
"""Optional docstring. There should be no function body."""
711+
"""Optional docstring. There should be no function body."""
712712

713713
The body of the decorated function is ignored, and any parameters that are
714714
missing type annotations are skipped. The names of the parameters are ignored
@@ -728,7 +728,7 @@ Specifying function pointers using type annotations
728728

729729
@wrap_dll_function(ctypes.pythonapi)
730730
def PyObject_GetAttrString(op: ctypes.py_object, attr: ctypes.c_char_p) -> ctypes.py_object:
731-
pass
731+
pass
732732

733733
PyObject_GetAttrString(42, b"real")
734734

@@ -3207,7 +3207,7 @@ fields, or any other data types containing pointer type fields.
32073207
that should be merged into a containing structure or union.
32083208

32093209

3210-
.. decorator:: struct(*, align=None, layout, endian='native', pack=None)
3210+
.. decorator:: struct(*, align=None, layout=None, endian='native', pack=None)
32113211
:module: ctypes.util
32123212

32133213
A :term:`decorator` that allows generating structure types using an
@@ -3244,14 +3244,18 @@ fields, or any other data types containing pointer type fields.
32443244

32453245
.. code-block:: python
32463246
3247+
from typing import Annotated
3248+
from ctypes import c_ssize_t, c_void_p
3249+
from ctypes.util import struct, CFieldInfo
3250+
32473251
@struct
32483252
class PyObject:
3249-
ob_refcnt: c_ssize_t
3250-
ob_type: c_void_p
3253+
ob_refcnt: c_ssize_t
3254+
ob_type: c_void_p
32513255
32523256
@struct
32533257
class PyHovercraftObject:
3254-
ob_base: Annotated[PyObject, CFieldInfo(anonymous=True)]
3258+
ob_base: Annotated[PyObject, CFieldInfo(anonymous=True)]
32553259
32563260
.. versionadded:: next
32573261

Doc/library/dis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ iterations of the loop.
14271427

14281428
``STACK[-1]`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` method.
14291429
If this yields a new value, push it on the stack (leaving the iterator below
1430-
it). If the iterator indicates it is exhausted then the byte code counter is
1430+
it). If the iterator indicates it is :term:`exhausted` then the byte code counter is
14311431
incremented by *delta*.
14321432

14331433
.. versionchanged:: 3.12

Doc/library/functions.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ are always available. They are listed here in alphabetical order.
129129
anext(async_iterator, default, /)
130130

131131
When awaited, return the next item from the given :term:`asynchronous
132-
iterator`, or *default* if given and the iterator is exhausted.
132+
iterator`, or *default* if given and the iterator is :term:`exhausted`.
133133

134134
This is the async variant of the :func:`next` builtin, and behaves
135135
similarly.
@@ -1223,7 +1223,7 @@ are always available. They are listed here in alphabetical order.
12231223
process_block(block)
12241224

12251225
*stop_exception* is useful for callables
1226-
which report exhaustion by raising an exception
1226+
which report :term:`exhaustion <exhausted>` by raising an exception
12271227
instead of returning a special value.
12281228
For example, draining a queue::
12291229

@@ -1315,7 +1315,7 @@ are always available. They are listed here in alphabetical order.
13151315
yielding the results. If additional *iterables* arguments are passed,
13161316
*function* must take that many arguments and is applied to the items from all
13171317
iterables in parallel. With multiple iterables, the iterator stops when the
1318-
shortest iterable is exhausted. If *strict* is ``True`` and one of the
1318+
shortest iterable is :term:`exhausted`. If *strict* is ``True`` and one of the
13191319
iterables is exhausted before the others, a :exc:`ValueError` is raised. For
13201320
cases where the function inputs are already arranged into argument tuples,
13211321
see :func:`itertools.starmap`.
@@ -1397,7 +1397,7 @@ are always available. They are listed here in alphabetical order.
13971397

13981398
Retrieve the next item from the :term:`iterator` by calling its
13991399
:meth:`~iterator.__next__` method. If *default* is given, it is returned
1400-
if the iterator is exhausted, otherwise :exc:`StopIteration` is raised.
1400+
if the iterator is :term:`exhausted`, otherwise :exc:`StopIteration` is raised.
14011401

14021402

14031403
.. class:: object()
@@ -2312,7 +2312,7 @@ are always available. They are listed here in alphabetical order.
23122312
the code that prepared these iterables. Python offers three different
23132313
approaches to dealing with this issue:
23142314

2315-
* By default, :func:`zip` stops when the shortest iterable is exhausted.
2315+
* By default, :func:`zip` stops when the shortest iterable is :term:`exhausted`.
23162316
It will ignore the remaining items in the longer iterables, cutting off
23172317
the result to the length of the shortest iterable::
23182318

@@ -2327,7 +2327,7 @@ are always available. They are listed here in alphabetical order.
23272327
[('a', 1), ('b', 2), ('c', 3)]
23282328

23292329
Unlike the default behavior, it raises a :exc:`ValueError` if one iterable
2330-
is exhausted before the others:
2330+
is :term:`exhausted` before the others:
23312331

23322332
>>> for item in zip(range(3), ['fee', 'fi', 'fo', 'fum'], strict=True): # doctest: +SKIP
23332333
... print(item)

Doc/library/http.client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ HTTPConnection Objects
277277
instance of :class:`io.TextIOBase`, the data returned by the ``read()``
278278
method will be encoded as ISO-8859-1, otherwise the data returned by
279279
``read()`` is sent as is. If *body* is an iterable, the elements of the
280-
iterable are sent as is until the iterable is exhausted.
280+
iterable are sent as is until the iterable is :term:`exhausted`.
281281

282282
The *headers* argument should be a mapping of extra HTTP headers to send
283283
with the request. A :rfc:`Host header <2616#section-14.23>`

0 commit comments

Comments
 (0)