mirror of https://github.com/python/cpython.git
bpo-34485: Emit C locale coercion warning later (GH-9002)
PYTHONCOERCELOCALE=warn warning is now emitted later and written into sys.stderr, rather than being written into the C stderr stream.
This commit is contained in:
parent
3d4226a832
commit
cf21504194
|
@ -301,10 +301,8 @@ static const char *_C_LOCALE_WARNING =
|
||||||
static void
|
static void
|
||||||
_emit_stderr_warning_for_legacy_locale(const _PyCoreConfig *core_config)
|
_emit_stderr_warning_for_legacy_locale(const _PyCoreConfig *core_config)
|
||||||
{
|
{
|
||||||
if (core_config->coerce_c_locale_warn) {
|
if (core_config->coerce_c_locale_warn && _Py_LegacyLocaleDetected()) {
|
||||||
if (_Py_LegacyLocaleDetected()) {
|
PySys_FormatStderr("%s", _C_LOCALE_WARNING);
|
||||||
fprintf(stderr, "%s", _C_LOCALE_WARNING);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,10 +565,6 @@ _Py_InitializeCore_impl(PyInterpreterState **interp_p,
|
||||||
*/
|
*/
|
||||||
_PyRuntime.finalizing = NULL;
|
_PyRuntime.finalizing = NULL;
|
||||||
|
|
||||||
#ifndef MS_WINDOWS
|
|
||||||
_emit_stderr_warning_for_legacy_locale(core_config);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
err = _Py_HashRandomization_Init(core_config);
|
err = _Py_HashRandomization_Init(core_config);
|
||||||
if (_Py_INIT_FAILED(err)) {
|
if (_Py_INIT_FAILED(err)) {
|
||||||
return err;
|
return err;
|
||||||
|
@ -867,6 +861,11 @@ _Py_InitializeMainInterpreter(PyInterpreterState *interp,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MS_WINDOWS
|
||||||
|
_emit_stderr_warning_for_legacy_locale(core_config);
|
||||||
|
#endif
|
||||||
|
|
||||||
return _Py_INIT_OK();
|
return _Py_INIT_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue