Skip to content

Commit a6b78d7

Browse files
committed
Merge branch 'master' into fix-deccheck.py/149755
2 parents 2aabbc9 + e12ee02 commit a6b78d7

51 files changed

Lines changed: 2789 additions & 734 deletions

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/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/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

Include/internal/pycore_intrinsics.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#define INTRINSIC_TYPEVAR_WITH_CONSTRAINTS 3
3131
#define INTRINSIC_SET_FUNCTION_TYPE_PARAMS 4
3232
#define INTRINSIC_SET_TYPEPARAM_DEFAULT 5
33+
#define INTRINSIC_ADD_CONDITIONAL_ANNOTATION 6
3334

34-
#define MAX_INTRINSIC_2 5
35+
#define MAX_INTRINSIC_2 6
3536

3637
typedef PyObject *(*intrinsic_func1)(PyThreadState* tstate, PyObject *value);
3738
typedef PyObject *(*intrinsic_func2)(PyThreadState* tstate, PyObject *value1, PyObject *value2);

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Known values:
302302
Python 3.16a1 3702 (Replace DELETE_NAME with PUSH_NULL; STORE_NAME)
303303
Python 3.16a1 3703 (Replace DELETE_GLOBAL with PUSH_NULL; STORE_GLOBAL)
304304
Python 3.16a1 3704 (Replace DELETE_ATTR with PUSH_NULL; STORE_ATTR)
305-
305+
Python 3.16a1 3705 (Add INTRINSIC_ADD_CONDITIONAL_ANNOTATION)
306306
307307
Python 3.17 will start with 3750
308308
@@ -312,7 +312,7 @@ Known values:
312312
313313
*/
314314

315-
#define PYC_MAGIC_NUMBER 3704
315+
#define PYC_MAGIC_NUMBER 3705
316316
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
317317
(little-endian) and then appending b'\r\n'. */
318318
#define PYC_MAGIC_NUMBER_TOKEN \

Lib/argparse.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,12 @@ def __eq__(self, other):
15451545
def __contains__(self, key):
15461546
return key in self.__dict__
15471547

1548+
def __replace__(self, /, **changes):
1549+
new = self.__class__()
1550+
new.__dict__.update(self.__dict__)
1551+
new.__dict__.update(changes)
1552+
return new
1553+
15481554

15491555
class _ActionsContainer(object):
15501556

@@ -1964,6 +1970,9 @@ def _prog_name(prog=None):
19641970
if modspec is None:
19651971
# simple script
19661972
return _os.path.basename(arg0)
1973+
if modspec.name != '__main__' and arg0 != modspec.origin:
1974+
# named module executed as main without altering sys.argv[0]
1975+
return _os.path.basename(arg0)
19671976
py = _os.path.basename(_sys.executable)
19681977
if modspec.name != '__main__':
19691978
# imported module or package

0 commit comments

Comments
 (0)