@@ -142,7 +142,7 @@ static const PyConfigSpec PYCONFIG_SPEC[] = {
142142 SPEC (hash_seed , ULONG , READ_ONLY , NO_SYS ),
143143 SPEC (home , WSTR_OPT , READ_ONLY , NO_SYS ),
144144 SPEC (thread_inherit_context , INT , READ_ONLY , NO_SYS ),
145- SPEC (thread_safe_warnings , INT , READ_ONLY , NO_SYS ),
145+ SPEC (context_aware_warnings , INT , READ_ONLY , NO_SYS ),
146146 SPEC (import_time , BOOL , READ_ONLY , NO_SYS ),
147147 SPEC (install_signal_handlers , BOOL , READ_ONLY , NO_SYS ),
148148 SPEC (isolated , BOOL , READ_ONLY , NO_SYS ), // sys.flags.isolated
@@ -330,12 +330,11 @@ The following implementation-specific options are available:\n\
330330-X thread_inherit_context=[0|1]: enable (1) or disable (0) threads inheriting\n\
331331 context vars by default; enabled by default in the free-threaded\n\
332332 build and disabled otherwise; also PYTHON_THREAD_INHERIT_CONTEXT\n\
333- -X thread_safe_warnings=[0|1]: if true (1) then the warnings module will\n\
334- use a context variable to store warnings filtering state, making it\n\
335- safe to use in multi-threaded programs; if false (0) then the\n\
336- warnings module will use module globals, which is not thread-safe;\n\
337- set to true for free-threaded builds and false otherwise; also\n\
338- PYTHON_THREAD_SAFE_WARNINGS\n\
333+ -X context_aware_warnings=[0|1]: if true (1) then the warnings module will\n\
334+ use a context variables; if false (0) then the warnings module will\n\
335+ use module globals, which is not concurrent-safe; set to true for\n\
336+ free-threaded builds and false otherwise; also\n\
337+ PYTHON_CONTEXT_AWARE_WARNINGS\n\
339338-X tracemalloc[=N]: trace Python memory allocations; N sets a traceback limit\n \
340339 of N frames (default: 1); also PYTHONTRACEMALLOC=N\n\
341340-X utf8[=0|1]: enable (1) or disable (0) UTF-8 mode; also PYTHONUTF8\n\
@@ -425,8 +424,8 @@ static const char usage_envvars[] =
425424#endif
426425"PYTHON_THREAD_INHERIT_CONTEXT: if true (1), threads inherit context vars\n"
427426" (-X thread_inherit_context)\n"
428- "PYTHON_THREAD_SAFE_WARNINGS : if true (1), enable thread-safe warnings module\n"
429- " behaviour (-X thread_safe_warnings )\n"
427+ "PYTHON_CONTEXT_AWARE_WARNINGS : if true (1), enable thread-safe warnings module\n"
428+ " behaviour (-X context_aware_warnings )\n"
430429"PYTHONTRACEMALLOC: trace Python memory allocations (-X tracemalloc)\n"
431430"PYTHONUNBUFFERED: disable stdout/stderr buffering (-u)\n"
432431"PYTHONUTF8 : control the UTF-8 mode (-X utf8)\n"
@@ -903,7 +902,7 @@ config_check_consistency(const PyConfig *config)
903902 // config->use_frozen_modules is initialized later
904903 // by _PyConfig_InitImportConfig().
905904 assert (config -> thread_inherit_context >= 0 );
906- assert (config -> thread_safe_warnings >= 0 );
905+ assert (config -> context_aware_warnings >= 0 );
907906#ifdef __APPLE__
908907 assert (config -> use_system_logger >= 0 );
909908#endif
@@ -1011,10 +1010,10 @@ _PyConfig_InitCompatConfig(PyConfig *config)
10111010 config -> cpu_count = -1 ;
10121011#ifdef Py_GIL_DISABLED
10131012 config -> thread_inherit_context = 1 ;
1014- config -> thread_safe_warnings = 1 ;
1013+ config -> context_aware_warnings = 1 ;
10151014#else
10161015 config -> thread_inherit_context = 0 ;
1017- config -> thread_safe_warnings = 0 ;
1016+ config -> context_aware_warnings = 0 ;
10181017#endif
10191018#ifdef __APPLE__
10201019 config -> use_system_logger = 0 ;
@@ -1050,10 +1049,10 @@ config_init_defaults(PyConfig *config)
10501049#endif
10511050#ifdef Py_GIL_DISABLED
10521051 config -> thread_inherit_context = 1 ;
1053- config -> thread_safe_warnings = 1 ;
1052+ config -> context_aware_warnings = 1 ;
10541053#else
10551054 config -> thread_inherit_context = 0 ;
1056- config -> thread_safe_warnings = 0 ;
1055+ config -> context_aware_warnings = 0 ;
10571056#endif
10581057#ifdef __APPLE__
10591058 config -> use_system_logger = 0 ;
@@ -1950,27 +1949,27 @@ config_init_thread_inherit_context(PyConfig *config)
19501949}
19511950
19521951static PyStatus
1953- config_init_thread_safe_warnings (PyConfig * config )
1952+ config_init_context_aware_warnings (PyConfig * config )
19541953{
1955- const char * env = config_get_env (config , "PYTHON_THREAD_SAFE_WARNINGS " );
1954+ const char * env = config_get_env (config , "PYTHON_CONTEXT_AWARE_WARNINGS " );
19561955 if (env ) {
19571956 int enabled ;
19581957 if (_Py_str_to_int (env , & enabled ) < 0 || (enabled < 0 ) || (enabled > 1 )) {
19591958 return _PyStatus_ERR (
1960- "PYTHON_THREAD_SAFE_WARNINGS =N: N is missing or invalid" );
1959+ "PYTHON_CONTEXT_AWARE_WARNINGS =N: N is missing or invalid" );
19611960 }
1962- config -> thread_safe_warnings = enabled ;
1961+ config -> context_aware_warnings = enabled ;
19631962 }
19641963
1965- const wchar_t * xoption = config_get_xoption (config , L"thread_safe_warnings " );
1964+ const wchar_t * xoption = config_get_xoption (config , L"context_aware_warnings " );
19661965 if (xoption ) {
19671966 int enabled ;
19681967 const wchar_t * sep = wcschr (xoption , L'=' );
19691968 if (!sep || (config_wstr_to_int (sep + 1 , & enabled ) < 0 ) || (enabled < 0 ) || (enabled > 1 )) {
19701969 return _PyStatus_ERR (
1971- "-X thread_safe_warnings =n: n is missing or invalid" );
1970+ "-X context_aware_warnings =n: n is missing or invalid" );
19721971 }
1973- config -> thread_safe_warnings = enabled ;
1972+ config -> context_aware_warnings = enabled ;
19741973 }
19751974 return _PyStatus_OK ();
19761975}
@@ -2259,7 +2258,7 @@ config_read_complex_options(PyConfig *config)
22592258 return status ;
22602259 }
22612260
2262- status = config_init_thread_safe_warnings (config );
2261+ status = config_init_context_aware_warnings (config );
22632262 if (_PyStatus_EXCEPTION (status )) {
22642263 return status ;
22652264 }
0 commit comments