@@ -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
123123of 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+
125137New 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
10321056Other language changes
10331057======================
0 commit comments