Skip to content

Commit 6798b27

Browse files
authored
Merge branch 'main' into remove-dec-bench/149755
2 parents 833f1ee + d2f4649 commit 6798b27

55 files changed

Lines changed: 2790 additions & 845 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_lock.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -212,40 +212,6 @@ PyAPI_FUNC(void) _PyRWMutex_RUnlock(_PyRWMutex *rwmutex);
212212
PyAPI_FUNC(void) _PyRWMutex_Lock(_PyRWMutex *rwmutex);
213213
PyAPI_FUNC(void) _PyRWMutex_Unlock(_PyRWMutex *rwmutex);
214214

215-
// Similar to linux seqlock: https://en.wikipedia.org/wiki/Seqlock
216-
// We use a sequence number to lock the writer, an even sequence means we're unlocked, an odd
217-
// sequence means we're locked. Readers will read the sequence before attempting to read the
218-
// underlying data and then read the sequence number again after reading the data. If the
219-
// sequence has not changed the data is valid.
220-
//
221-
// Differs a little bit in that we use CAS on sequence as the lock, instead of a separate spin lock.
222-
// The writer can also detect that the undelering data has not changed and abandon the write
223-
// and restore the previous sequence.
224-
typedef struct {
225-
uint32_t sequence;
226-
} _PySeqLock;
227-
228-
// Lock the sequence lock for the writer
229-
PyAPI_FUNC(void) _PySeqLock_LockWrite(_PySeqLock *seqlock);
230-
231-
// Unlock the sequence lock and move to the next sequence number.
232-
PyAPI_FUNC(void) _PySeqLock_UnlockWrite(_PySeqLock *seqlock);
233-
234-
// Abandon the current update indicating that no mutations have occurred
235-
// and restore the previous sequence value.
236-
PyAPI_FUNC(void) _PySeqLock_AbandonWrite(_PySeqLock *seqlock);
237-
238-
// Begin a read operation and return the current sequence number.
239-
PyAPI_FUNC(uint32_t) _PySeqLock_BeginRead(_PySeqLock *seqlock);
240-
241-
// End the read operation and confirm that the sequence number has not changed.
242-
// Returns 1 if the read was successful or 0 if the read should be retried.
243-
PyAPI_FUNC(int) _PySeqLock_EndRead(_PySeqLock *seqlock, uint32_t previous);
244-
245-
// Check if the lock was held during a fork and clear the lock. Returns 1
246-
// if the lock was held and any associated data should be cleared.
247-
PyAPI_FUNC(int) _PySeqLock_AfterFork(_PySeqLock *seqlock);
248-
249215
#ifdef __cplusplus
250216
}
251217
#endif

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 \

0 commit comments

Comments
 (0)