Version-Specific Features

Python 3.14 — Context-aware warning filters

Warnings can use context-local filter state instead of global filter mutation. The flag defaults to enabled for free-threaded builds and disabled for ordinary GIL builds. Thread context inheritance is a separate setting. Requires Python 3.14 or the relevant build; example is not executed locally.

Formal Syntax & Structure

python syntaxpython
python -X context_aware_warnings=1 script.py

Return Value

Feature-specific

No single return type; see the example and feature description.

Working Example

Example Snippetpython
# Run with -X context_aware_warnings=1import sys, warningswith warnings.catch_warnings(record=True) as seen:    warnings.simplefilter('always')    warnings.warn('example')    print(sys.flags.context_aware_warnings, len(seen))
Python Reference