Skip to content

Commit 5654235

Browse files
committed
Add whatsnew text for warnings module changes.
1 parent a8ec511 commit 5654235

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ it's safe to do so. This can lead to different values returned from
122122
:func:`sys.getrefcount` and :c:func:`Py_REFCNT` compared to previous versions
123123
of Python. See :ref:`below <whatsnew314-refcount>` for details.
124124

125+
A new flag has been added, :data:`~sys.flags.context_aware_warnings`. This
126+
flag defaults to true for the free-threaded build and false for the GIL-enabled
127+
build. If the flag is true then the :class:`warnings.catch_warnings` context
128+
manager uses a context variable for warning filters.
129+
130+
A new flag has been added, :data:`~sys.flags.thread_inherit_context`. This
131+
flag defaults to true for the free-threaded build and false for the GIL-enabled
132+
build. If the flag is true then threads created with :class:`threading.Thread`
133+
start with a copy of the :class:`~contextvars.Context()` of the caller of
134+
:meth:`~threading.Thread.start`.
135+
136+
125137
New features
126138
============
127139

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

10291041
.. seealso:: :pep:`744`
10301042

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

10321056
Other language changes
10331057
======================

0 commit comments

Comments
 (0)