Skip to content

Commit 7bc6ab7

Browse files
authored
Merge branch '3.14' into 133600-backport-wasi-file-reorg
2 parents efc144d + 2045453 commit 7bc6ab7

File tree

23 files changed

+31624
-31562
lines changed

23 files changed

+31624
-31562
lines changed

Doc/data/python3.14.abi

Lines changed: 31549 additions & 31533 deletions
Large diffs are not rendered by default.

Doc/howto/functional.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ generators:
602602
raise an exception inside the generator; the exception is raised by the
603603
``yield`` expression where the generator's execution is paused.
604604

605-
* :meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the
605+
* :meth:`~generator.close` sends a :exc:`GeneratorExit` exception to the
606606
generator to terminate the iteration. On receiving this exception, the
607607
generator's code must either raise :exc:`GeneratorExit` or
608608
:exc:`StopIteration`; catching the exception and doing anything else is

Doc/howto/isolating-extensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ Avoiding ``PyObject_New``
453453

454454
GC-tracked objects need to be allocated using GC-aware functions.
455455

456-
If you use use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:
456+
If you use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:
457457

458458
- Get and call type's :c:member:`~PyTypeObject.tp_alloc` slot, if possible.
459459
That is, replace ``TYPE *o = PyObject_New(TYPE, typeobj)`` with::

Doc/library/logging.handlers.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,15 @@ possible, while any potentially slow operations (such as sending an email via
10591059
.. note:: If you are using :mod:`multiprocessing`, you should avoid using
10601060
:class:`~queue.SimpleQueue` and instead use :class:`multiprocessing.Queue`.
10611061

1062+
.. warning::
1063+
1064+
The :mod:`multiprocessing` module uses an internal logger created and
1065+
accessed via :meth:`~multiprocessing.get_logger`.
1066+
:class:`multiprocessing.Queue` will log ``DEBUG`` level messages upon
1067+
items being queued. If those log messages are processed by a
1068+
:class:`QueueHandler` using the same :class:`multiprocessing.Queue` instance,
1069+
it will cause a deadlock or infinite recursion.
1070+
10621071
.. method:: emit(record)
10631072

10641073
Enqueues the result of preparing the LogRecord. Should an exception

Doc/reference/expressions.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,10 @@ is already executing raises a :exc:`ValueError` exception.
625625

626626
.. method:: generator.close()
627627

628-
Raises a :exc:`GeneratorExit` at the point where the generator function was
629-
paused. If the generator function catches the exception and returns a
628+
Raises a :exc:`GeneratorExit` exception at the point where the generator
629+
function was paused (equivalent to calling ``throw(GeneratorExit)``).
630+
The exception is raised by the yield expression where the generator was paused.
631+
If the generator function catches the exception and returns a
630632
value, this value is returned from :meth:`close`. If the generator function
631633
is already closed, or raises :exc:`GeneratorExit` (by not catching the
632634
exception), :meth:`close` returns :const:`None`. If the generator yields a

Doc/whatsnew/3.14.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,23 @@ be specified by the build backend, as it will no longer be determined
978978
automatically by the C compiler. For a running interpreter, the setting that
979979
was used at compile time can be found using :func:`sysconfig.get_config_var`.
980980

981+
A new flag has been added, :data:`~sys.flags.context_aware_warnings`. This
982+
flag defaults to true for the free-threaded build and false for the GIL-enabled
983+
build. If the flag is true then the :class:`warnings.catch_warnings` context
984+
manager uses a context variable for warning filters. This makes the context
985+
manager behave predicably when used with multiple threads or asynchronous
986+
tasks.
987+
988+
A new flag has been added, :data:`~sys.flags.thread_inherit_context`. This flag
989+
defaults to true for the free-threaded build and false for the GIL-enabled
990+
build. If the flag is true then threads created with :class:`threading.Thread`
991+
start with a copy of the :class:`~contextvars.Context()` of the caller of
992+
:meth:`~threading.Thread.start`. Most significantly, this makes the warning
993+
filtering context established by :class:`~warnings.catch_warnings` be
994+
"inherited" by threads (or asyncio tasks) started within that context. It also
995+
affects other modules that use context variables, such as the :mod:`decimal`
996+
context manager.
997+
981998

982999
.. _whatsnew314-pyrepl-highlighting:
9831000

@@ -1028,6 +1045,18 @@ Please report any bugs or major performance regressions that you encounter!
10281045

10291046
.. seealso:: :pep:`744`
10301047

1048+
Concurrent safe warnings control
1049+
--------------------------------
1050+
1051+
The :class:`warnings.catch_warnings` context manager will now optionally
1052+
use a context variable for warning filters. This is enabled by setting
1053+
the :data:`~sys.flags.context_aware_warnings` flag, either with the ``-X``
1054+
command-line option or an environment variable. This gives predicable
1055+
warnings control when using :class:`~warnings.catch_warnings` combined with
1056+
multiple threads or asynchronous tasks. The flag defaults to true for the
1057+
free-threaded build and false for the GIL-enabled build.
1058+
1059+
(Contributed by Neil Schemenauer and Kumar Aditya in :gh:`130010`.)
10311060

10321061
Other language changes
10331062
======================

Include/cpython/funcobject.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) {
9797
}
9898
#define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func))
9999

100-
static inline PyObject* PyFunction_GET_BUILTINS(PyObject *func) {
101-
return _PyFunction_CAST(func)->func_builtins;
102-
}
103-
#define PyFunction_GET_BUILTINS(func) PyFunction_GET_BUILTINS(_PyObject_CAST(func))
104-
105100
static inline PyObject* PyFunction_GET_MODULE(PyObject *func) {
106101
return _PyFunction_CAST(func)->func_module;
107102
}

Include/cpython/pystate.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ typedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *);
2828
#define PyTrace_OPCODE 7
2929

3030
/* Remote debugger support */
31-
#define MAX_SCRIPT_PATH_SIZE 512
32-
typedef struct _remote_debugger_support {
31+
#define Py_MAX_SCRIPT_PATH_SIZE 512
32+
typedef struct {
3333
int32_t debugger_pending_call;
34-
char debugger_script_path[MAX_SCRIPT_PATH_SIZE];
34+
char debugger_script_path[Py_MAX_SCRIPT_PATH_SIZE];
3535
} _PyRemoteDebuggerSupport;
3636

3737
typedef struct _err_stackitem {

Include/internal/pycore_debug_offsets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ typedef struct _Py_DebugOffsets {
368368
.remote_debugging_enabled = offsetof(PyInterpreterState, config.remote_debug), \
369369
.debugger_pending_call = offsetof(_PyRemoteDebuggerSupport, debugger_pending_call), \
370370
.debugger_script_path = offsetof(_PyRemoteDebuggerSupport, debugger_script_path), \
371-
.debugger_script_path_size = MAX_SCRIPT_PATH_SIZE, \
371+
.debugger_script_path_size = Py_MAX_SCRIPT_PATH_SIZE, \
372372
}, \
373373
}
374374

Include/internal/pycore_function.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ extern PyObject *_Py_set_function_type_params(
4141
PyAPI_FUNC(int)
4242
_PyFunction_VerifyStateless(PyThreadState *, PyObject *);
4343

44+
static inline PyObject* _PyFunction_GET_BUILTINS(PyObject *func) {
45+
return _PyFunction_CAST(func)->func_builtins;
46+
}
47+
#define _PyFunction_GET_BUILTINS(func) _PyFunction_GET_BUILTINS(_PyObject_CAST(func))
48+
4449

4550
#ifdef __cplusplus
4651
}

0 commit comments

Comments
 (0)