Skip to content

Commit 17aee3e

Browse files
Merge branch 'main' into pep-828/implementation
2 parents c1ac461 + e12ee02 commit 17aee3e

87 files changed

Lines changed: 3358 additions & 860 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.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Tools/unicode/data/
143143
/config.status.lineno
144144
/.ccache
145145
/cross-build*/
146+
/dist/
146147
/jit_stencils*.h
147148
/jit_unwind_info*.h
148149
.jit-stamp

Doc/c-api/frame.rst

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -269,29 +269,8 @@ Unless using :pep:`523`, you will not need this.
269269
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR
270270
- The frame corresponds to a method on a class instance.
271271
272-
However, Python's C API lacks a function to read the executable kind from
273-
a frame. Instead, use this recipe:
274-
275-
.. code-block:: c
276-
277-
int
278-
get_executable_kind(PyFrameObject *frame)
279-
{
280-
_PyInterpreterFrame *f = frame->f_frame;
281-
PyObject *exec = PyStackRef_AsPyObjectBorrow(f->f_executable);
282-
283-
if (PyCode_Check(exec)) {
284-
return PyUnstable_EXECUTABLE_KIND_PY_FUNCTION;
285-
}
286-
if (PyMethod_Check(exec)) {
287-
return PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION;
288-
}
289-
if (Py_IS_TYPE(exec, &PyMethodDescr_Type)) {
290-
return PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR;
291-
}
292-
293-
return PyUnstable_EXECUTABLE_KIND_SKIP;
294-
}
272+
Note that reading the executable kind from a frame is currently only
273+
possible with undocumented internal APIs.
295274
296275
.. versionadded:: 3.13
297276

Doc/library/argparse.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,12 @@ The Namespace object
16791679
Simple class used by default by :meth:`~ArgumentParser.parse_args` to create
16801680
an object holding attributes and return it.
16811681

1682+
:class:`!Namespace` objects support :func:`copy.replace`,
1683+
which returns a copy of the object with the specified attributes replaced.
1684+
1685+
.. versionchanged:: next
1686+
Added support for :func:`copy.replace`.
1687+
16821688
This class is deliberately simple, just an :class:`object` subclass with a
16831689
readable string representation. If you prefer to have dict-like view of the
16841690
attributes, you can use the standard Python idiom, :func:`vars`::

Doc/library/ast.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@ Comprehensions
806806
List and set comprehensions, generator expressions, and dictionary
807807
comprehensions. ``elt`` (or ``key`` and ``value``) is a single node
808808
representing the part that will be evaluated for each item.
809-
809+
For dictionary comprehensions using unpacking, for example
810+
``{**item for item in items}``, ``value`` is ``None``,
810811
``generators`` is a list of :class:`comprehension` nodes.
811812

812813
.. doctest::

Doc/library/asyncio-stream.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,16 @@ StreamWriter
389389
be resumed. When there is nothing to wait for, the :meth:`drain`
390390
returns immediately.
391391

392+
.. note::
393+
394+
When the write buffer is below the high watermark,
395+
:meth:`drain` returns immediately without yielding to
396+
the event loop. As a result, code which repeatedly calls
397+
``write()`` followed by ``await drain()`` may prevent other
398+
tasks from running. To prevent blocking behavior, yield
399+
to the event loop explicitly with ``await asyncio.sleep(0)``
400+
(see :func:`asyncio.sleep`).
401+
392402
.. method:: start_tls(sslcontext, *, server_hostname=None, \
393403
ssl_handshake_timeout=None, ssl_shutdown_timeout=None)
394404
:async:

Doc/library/asyncio-task.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,17 @@ Creating tasks
288288
# completion:
289289
task.add_done_callback(background_tasks.discard)
290290

291+
Note that this approach never awaits the tasks, so if a task
292+
fails, its exception is never retrieved and asyncio logs a
293+
"Task exception was never retrieved" message when the task is
294+
garbage collected. To avoid this, use :class:`asyncio.TaskGroup`
295+
which keeps a strong reference to each task, awaits them and
296+
propagates their exceptions::
297+
298+
async with asyncio.TaskGroup() as tg:
299+
for i in range(10):
300+
tg.create_task(some_coro(param=i))
301+
291302
.. versionadded:: 3.7
292303

293304
.. versionchanged:: 3.8

Doc/library/dis.rst

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,25 +1899,29 @@ iterations of the loop.
18991899

19001900
The operand determines which intrinsic function is called:
19011901

1902-
+----------------------------------------+-----------------------------------+
1903-
| Operand | Description |
1904-
+========================================+===================================+
1905-
| ``INTRINSIC_2_INVALID`` | Not valid |
1906-
+----------------------------------------+-----------------------------------+
1907-
| ``INTRINSIC_PREP_RERAISE_STAR`` | Calculates the |
1908-
| | :exc:`ExceptionGroup` to raise |
1909-
| | from a ``try-except*``. |
1910-
+----------------------------------------+-----------------------------------+
1911-
| ``INTRINSIC_TYPEVAR_WITH_BOUND`` | Creates a :class:`typing.TypeVar` |
1912-
| | with a bound. |
1913-
+----------------------------------------+-----------------------------------+
1914-
| ``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS`` | Creates a |
1915-
| | :class:`typing.TypeVar` with |
1916-
| | constraints. |
1917-
+----------------------------------------+-----------------------------------+
1918-
| ``INTRINSIC_SET_FUNCTION_TYPE_PARAMS`` | Sets the ``__type_params__`` |
1919-
| | attribute of a function. |
1920-
+----------------------------------------+-----------------------------------+
1902+
+------------------------------------------+-----------------------------------+
1903+
| Operand | Description |
1904+
+==========================================+===================================+
1905+
| ``INTRINSIC_2_INVALID`` | Not valid |
1906+
+------------------------------------------+-----------------------------------+
1907+
| ``INTRINSIC_PREP_RERAISE_STAR`` | Calculates the |
1908+
| | :exc:`ExceptionGroup` to raise |
1909+
| | from a ``try-except*``. |
1910+
+------------------------------------------+-----------------------------------+
1911+
| ``INTRINSIC_TYPEVAR_WITH_BOUND`` | Creates a :class:`typing.TypeVar` |
1912+
| | with a bound. |
1913+
+------------------------------------------+-----------------------------------+
1914+
| ``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS`` | Creates a |
1915+
| | :class:`typing.TypeVar` with |
1916+
| | constraints. |
1917+
+------------------------------------------+-----------------------------------+
1918+
| ``INTRINSIC_SET_FUNCTION_TYPE_PARAMS`` | Sets the ``__type_params__`` |
1919+
| | attribute of a function. |
1920+
+------------------------------------------+-----------------------------------+
1921+
| ``INTRINSIC_ADD_CONDITIONAL_ANNOTATION`` | Adds an annotation index to the |
1922+
| | ``__conditional_annotations__`` |
1923+
| | set. |
1924+
+------------------------------------------+-----------------------------------+
19211925

19221926
.. versionadded:: 3.12
19231927

Doc/library/os.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
14481448
Return a pair of file descriptors ``(r, w)`` usable for reading and writing,
14491449
respectively.
14501450

1451-
.. availability:: Unix, not WASI, not macOS, not iOS.
1451+
.. availability:: Unix, macOS >= 27.0, not WASI, not iOS.
14521452

14531453
.. versionadded:: 3.3
14541454

Doc/library/stdtypes.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4871,7 +4871,7 @@ copying.
48714871
.. versionadded:: 3.2
48724872

48734873
.. method:: cast(format, /)
4874-
cast(format, shape, /)
4874+
cast(format, shape, /, *, order='C')
48754875
48764876
Cast a memoryview to a new format or shape. *shape* defaults to
48774877
``[byte_length//new_itemsize]``, which means that the result view
@@ -4880,6 +4880,12 @@ copying.
48804880
1D -> C-:term:`contiguous`, C-contiguous -> 1D, and
48814881
F-contiguous -> 1D.
48824882

4883+
With a multidimensional *shape*, *order* selects the memory layout of
4884+
the result: ``'C'`` for C-contiguous (row-major, the default) or ``'F'``
4885+
for Fortran-contiguous (column-major). The buffer is still not copied,
4886+
so ``order='F'`` gives a zero-copy view over a buffer holding
4887+
column-major data.
4888+
48834889
The destination format is restricted to a single element native format in
48844890
:mod:`struct` syntax. One of the formats must be a byte format
48854891
('B', 'b' or 'c'). The byte length of the result must be the same
@@ -5031,8 +5037,20 @@ copying.
50315037
>>> y.nbytes
50325038
96
50335039

5040+
Interpret a flat buffer as a Fortran-contiguous (column-major) array::
5041+
5042+
>>> buf = bytes(range(6))
5043+
>>> y = memoryview(buf).cast('B', shape=[3, 2], order='F')
5044+
>>> y.f_contiguous
5045+
True
5046+
>>> y.tolist()
5047+
[[0, 3], [1, 4], [2, 5]]
5048+
50345049
.. versionadded:: 3.3
50355050

5051+
.. versionchanged:: next
5052+
Added the *order* parameter.
5053+
50365054
.. attribute:: readonly
50375055

50385056
A bool indicating whether the memory is read only.

Doc/library/test.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ The :mod:`!test.support` module defines the following functions:
963963

964964
.. currentmodule:: test.support.isolation
965965

966-
.. decorator:: runInSubprocess()
966+
.. decorator:: runInSubprocess(*, options=(), env=None, timeout=None)
967967

968968
Decorator that runs the decorated test in a fresh interpreter subprocess, in
969969
isolation, so that it does not share global or interpreter state with the
@@ -997,6 +997,19 @@ The :mod:`!test.support` module defines the following functions:
997997
:func:`~test.support.bigmemtest` and the like behave consistently in both
998998
processes.
999999

1000+
*options* is a sequence of interpreter command line options
1001+
to run the subprocess with,
1002+
and *env* is a mapping of environment variables to set in it,
1003+
on top of the inherited environment.
1004+
A value of ``None`` in *env* unsets the variable.
1005+
Note that :option:`-E` and :option:`-I` make the subprocess ignore
1006+
the ``PYTHON*`` environment variables, including :envvar:`PYTHONPATH`.
1007+
1008+
*timeout* is the number of seconds to wait for the subprocess;
1009+
the test is reported as an error if it does not complete in time.
1010+
By default there is no timeout,
1011+
and a hung test is left to the timeout of the test runner.
1012+
10001013
The test is skipped on platforms without subprocess support.
10011014

10021015

0 commit comments

Comments
 (0)