Skip to content

Commit 9602c13

Browse files
authored
Merge branch 'main' into warsaw/timthis
2 parents c0e49f2 + 910a92b commit 9602c13

92 files changed

Lines changed: 1520 additions & 843 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.

‎.github/ISSUE_TEMPLATE/documentation.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ body:
77
value: |
88
> [!NOTE]
99
> Trivial changes (for example typos) don’t require an issue before opening a PR.
10+
- type: input
11+
id: url
12+
attributes:
13+
label: "Documentation URL"
14+
description: "A link to the relevant documentation page, if applicable."
15+
placeholder: "https://docs.python.org/3/..."
1016
- type: textarea
1117
id: description
1218
attributes:
1319
label: "Documentation"
14-
description: "A clear and concise description of the issue. Include a link to the page."
20+
description: "A clear and concise description of the issue."
1521
validations:
1622
required: true

‎AGENTS.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,16 @@ When acting on this repository, apply the policy's core principles:
1414
- Follow existing coding style and patterns.
1515
- Write tests that exercise the change.
1616
- Keep backwards compatibility with prior releases in mind.
17+
18+
## Opening issues
19+
20+
Do not auto-generate issues with AI tools.
21+
22+
Search GitHub for duplicate issues before opening a new issue. Do not open
23+
duplicates.
24+
25+
```bash
26+
gh search issues --repo python/cpython "<symptom keywords>"
27+
gh search issues --repo python/cpython "<function, module or option name>"
28+
gh issue list --repo python/cpython --state all --label "<topic label>" --search "<short area keywords>"
29+
```

‎Doc/c-api/dict.rst‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,14 @@ Dictionary objects
472472
473473
.. c:function:: int PyDict_Update(PyObject *a, PyObject *b)
474474
475-
This is the same as ``PyDict_Merge(a, b, 1)`` in C, and is similar to
476-
``a.update(b)`` in Python except that :c:func:`PyDict_Update` doesn't fall
477-
back to the iterating over a sequence of key value pairs if the second
478-
argument has no "keys" attribute. Return ``0`` on success or ``-1`` if an
479-
exception was raised.
475+
This is the same as ``PyDict_Merge(a, b, 1)`` in C.
476+
477+
Similar to ``a.update(b)`` in Python, except that this function
478+
does not fall back to the iterating over a sequence of key-value pairs
479+
if *b* is not a mapping.
480+
Use :c:func:`PyDict_MergeFromSeq2` for this case.
481+
482+
Return ``0`` on success or ``-1`` if an exception was raised.
480483
481484
.. note::
482485

‎Doc/data/refcounts.dat‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,9 @@ PyType_GenericNew:PyObject*:type:0:
24172417
PyType_GenericNew:PyObject*:args:0:
24182418
PyType_GenericNew:PyObject*:kwds:0:
24192419

2420+
PyType_GetDict:PyObject*::+1:
2421+
PyType_GetDict:PyTypeObject*:type:0:
2422+
24202423
PyType_GetFlags:unsigned long:::
24212424
PyType_GetFlags:PyTypeObject*:type:0:
24222425

‎Doc/library/dis.rst‎

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,14 @@ operations on it as if it was a Python list. The top of the stack corresponds to
621621

622622
.. opcode:: POP_ITER
623623

624-
Removes the iterator from the top of the stack.
624+
Removes the iterator and the value pushed with it by :opcode:`GET_ITER`
625+
from the top of the stack.
625626

626627
.. versionadded:: 3.14
627628

629+
.. versionchanged:: 3.15
630+
Two values are now removed.
631+
628632

629633
.. opcode:: POP_TOP
630634

@@ -644,11 +648,15 @@ operations on it as if it was a Python list. The top of the stack corresponds to
644648

645649
.. opcode:: END_SEND
646650

647-
Implements ``del STACK[-2]``.
651+
Implements ``del STACK[-3:-1]``.
648652
Used to clean up when a generator exits.
649653

650654
.. versionadded:: 3.12
651655

656+
.. versionchanged:: 3.15
657+
The receiver and the value pushed with it by :opcode:`GET_ITER` are
658+
removed, instead of only the receiver.
659+
652660

653661
.. opcode:: COPY (i)
654662

@@ -712,17 +720,23 @@ result back on the stack.
712720
Implements ``STACK[-1] = ~STACK[-1]``.
713721

714722

715-
.. opcode:: GET_ITER
716-
717-
Implements ``STACK[-1] = iter(STACK[-1])``.
723+
.. opcode:: GET_ITER (yield_from)
718724

725+
Replaces ``STACK[-1]`` with an iterator for it and pushes a second value,
726+
which is used by :opcode:`FOR_ITER`, :opcode:`SEND` and :opcode:`POP_ITER`.
719727

720-
.. opcode:: GET_YIELD_FROM_ITER
728+
For some built-in sequence types, such as :class:`list` and :class:`tuple`,
729+
the object itself is left on the stack as a "virtual iterator" and the
730+
index to start iterating from is pushed. Otherwise, implements
731+
``STACK[-1] = iter(STACK[-1])`` and pushes ``NULL``.
721732

722-
If ``STACK[-1]`` is a :term:`generator iterator` or :term:`coroutine` object
723-
it is left as is. Otherwise, implements ``STACK[-1] = iter(STACK[-1])``.
733+
If *yield_from* is non-zero, the instruction is used for ``yield from``:
734+
a :term:`coroutine` object is left as is, unless the current code is
735+
a regular generator, in which case :exc:`TypeError` is raised.
724736

725-
.. versionadded:: 3.5
737+
.. versionchanged:: 3.15
738+
A second value is now pushed after the iterator. The *yield_from*
739+
argument was added, replacing the ``GET_YIELD_FROM_ITER`` instruction.
726740

727741

728742
.. opcode:: TO_BOOL
@@ -1425,14 +1439,21 @@ iterations of the loop.
14251439

14261440
.. opcode:: FOR_ITER (delta)
14271441

1428-
``STACK[-1]`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` method.
1442+
``STACK[-2]`` is an :term:`iterator` (or a virtual iterator, see
1443+
:opcode:`GET_ITER`) and ``STACK[-1]`` is the value pushed with it by
1444+
:opcode:`GET_ITER`. Get the next item, calling the iterator's
1445+
:meth:`~iterator.__next__` method if needed.
14291446
If this yields a new value, push it on the stack (leaving the iterator below
14301447
it). If the iterator indicates it is :term:`exhausted` then the byte code counter is
14311448
incremented by *delta*.
14321449

14331450
.. versionchanged:: 3.12
14341451
Up until 3.11 the iterator was popped when it was exhausted.
14351452

1453+
.. versionchanged:: 3.15
1454+
The iterator is now followed on the stack by the value pushed with it
1455+
by :opcode:`GET_ITER`.
1456+
14361457
.. opcode:: LOAD_GLOBAL (namei)
14371458

14381459
Loads the global named ``co_names[namei>>1]`` onto the stack.
@@ -1810,15 +1831,21 @@ iterations of the loop.
18101831

18111832
.. opcode:: SEND (delta)
18121833

1813-
Equivalent to ``STACK[-1] = STACK[-2].send(STACK[-1])``. Used in ``yield from``
1814-
and ``await`` statements.
1834+
Equivalent to ``STACK[-1] = STACK[-3].send(STACK[-1])``. Used in ``yield from``
1835+
and ``await`` statements. ``STACK[-2]`` is the value pushed with the
1836+
receiver by :opcode:`GET_ITER`; if the receiver is a virtual iterator,
1837+
it is advanced as by :opcode:`FOR_ITER`.
18151838

18161839
If the call raises :exc:`StopIteration`, pop the top value from the stack,
18171840
push the exception's ``value`` attribute, and increment the bytecode counter
18181841
by *delta*.
18191842

18201843
.. versionadded:: 3.11
18211844

1845+
.. versionchanged:: 3.15
1846+
The receiver is now at ``STACK[-3]``, followed by the value pushed with
1847+
it by :opcode:`GET_ITER`.
1848+
18221849

18231850
.. opcode:: HAVE_ARGUMENT
18241851

‎Doc/library/http.client.rst‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ HTTPConnection Objects
312312
but there is a request body, one of those
313313
header fields will be added automatically. If
314314
*body* is ``None``, the Content-Length header is set to ``0`` for
315-
methods that expect a body (``PUT``, ``POST``, and ``PATCH``). If
315+
methods that expect a body (``PUT``, ``POST``, ``PATCH``, and ``QUERY``). If
316316
*body* is a string or a bytes-like object that is not also a
317317
:term:`file <file object>`, the Content-Length header is
318318
set to its length. Any other type of *body* (files
@@ -369,6 +369,9 @@ HTTPConnection Objects
369369
*continue_timeout* value must be greater than zero, otherwise
370370
:exc:`ValueError` is raised.
371371

372+
.. versionchanged:: next
373+
``QUERY`` was added to the methods that expect a body.
374+
372375
.. method:: HTTPConnection.getresponse(support_continue=False)
373376

374377
Should be called after a request is sent to get the response from the server.

‎Doc/library/http.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ Property Indicates that Details
194194
<HTTPMethod.PATCH>,
195195
<HTTPMethod.POST>,
196196
<HTTPMethod.PUT>,
197+
<HTTPMethod.QUERY>,
197198
<HTTPMethod.TRACE>]
198199

199200
.. _http-methods:
@@ -217,4 +218,5 @@ Method Enum Name Details
217218
``OPTIONS`` ``OPTIONS`` HTTP Semantics :rfc:`9110`, Section 9.3.7
218219
``TRACE`` ``TRACE`` HTTP Semantics :rfc:`9110`, Section 9.3.8
219220
``PATCH`` ``PATCH`` HTTP/1.1 :rfc:`5789`
221+
``QUERY`` ``QUERY`` The HTTP QUERY Method :rfc:`10008`
220222
=========== =================================== ==================================================================

‎Doc/library/ipaddress.rst‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ dictionaries.
739739
Traceback (most recent call last):
740740
File "<stdin>", line 1, in <module>
741741
raise ValueError(
742-
ValueError: next prefix must be between 1 and 32
742+
ValueError: prefix must be between 1 and 32
743743
>>> IPv4Network('255.255.255.0/24').next_network()
744744
Traceback (most recent call last):
745745
File "<stdin>", line 1, in <module>
@@ -748,6 +748,36 @@ dictionaries.
748748

749749
.. versionadded:: 3.16
750750

751+
.. method:: prev_network(prev_prefix=None)
752+
753+
Finds the previous closest network of prefix size *prev_prefix*. If
754+
*prev_prefix=None*, then the current network prefix will be used.
755+
Returns a single network object.
756+
757+
Raises :exc:`ValueError` if *prev_prefix* is out of range or no further
758+
network of the requested size exists.
759+
760+
>>> IPv4Network('192.0.2.0/24').prev_network()
761+
IPv4Network('192.0.1.0/24')
762+
>>> IPv4Network('192.0.2.0/24').prev_network(prev_prefix=25)
763+
IPv4Network('192.0.1.128/25')
764+
>>> IPv4Network('192.0.2.0/24').prev_network(prev_prefix=23)
765+
IPv4Network('192.0.0.0/23')
766+
>>> IPv4Network('192.0.80.0/22').prev_network(prev_prefix=18)
767+
IPv4Network('192.0.0.0/18')
768+
>>> IPv4Network('192.0.80.0/22').prev_network(prev_prefix=50)
769+
Traceback (most recent call last):
770+
File "<stdin>", line 1, in <module>
771+
raise ValueError(
772+
ValueError: prefix must be between 1 and 32
773+
>>> IPv4Network('0.0.0.0/24').prev_network()
774+
Traceback (most recent call last):
775+
File "<stdin>", line 1, in <module>
776+
raise ValueError(
777+
ValueError: out of address space, cannot make another /24 network
778+
779+
.. versionadded:: 3.16
780+
751781
.. class:: IPv6Network(address, strict=True)
752782

753783
Construct an IPv6 network definition. *address* can be one of the following:
@@ -820,6 +850,7 @@ dictionaries.
820850
.. method:: subnet_of(other)
821851
.. method:: supernet_of(other)
822852
.. method:: next_network(next_prefix=None)
853+
.. method:: prev_network(prev_prefix=None)
823854
.. method:: compare_networks(other)
824855

825856
Refer to the corresponding attribute documentation in

‎Doc/library/shutil.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,9 @@ Directory and files operations
532532
or ends with an extension that is in ``PATHEXT``; and filenames that
533533
have no extension can now be found.
534534

535+
.. versionchanged:: next
536+
Accepts a :term:`path-like object` for *cmd*.
537+
535538
.. exception:: Error
536539

537540
Subclass of :exc:`OSError` collecting exceptions raised during a multi-file

‎Doc/tools/removed-ids.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ library/asyncio-task.html: terminating-a-task-group
3434
library/dis.html: opcode-DELETE_ATTR
3535
library/dis.html: opcode-DELETE_GLOBAL
3636
library/dis.html: opcode-DELETE_NAME
37+
library/dis.html: opcode-GET_YIELD_FROM_ITER
3738
library/asyncio-llapi-index.html: event-loop-policies
3839

3940
deprecations/index.html: pending-removal-in-python-3-15

0 commit comments

Comments
 (0)