bpo-34485: Emit C locale coercion warning later (GH-9002) · python/cpython@cf21504

@@ -301,10 +301,8 @@ static const char *_C_LOCALE_WARNING =

301301

static void

302302

_emit_stderr_warning_for_legacy_locale(const _PyCoreConfig *core_config)

303303

{

304-

if (core_config->coerce_c_locale_warn) {

305-

if (_Py_LegacyLocaleDetected()) {

306-

fprintf(stderr, "%s", _C_LOCALE_WARNING);

307-

}

304+

if (core_config->coerce_c_locale_warn && _Py_LegacyLocaleDetected()) {

305+

PySys_FormatStderr("%s", _C_LOCALE_WARNING);

308306

}

309307

}

310308

@@ -567,10 +565,6 @@ _Py_InitializeCore_impl(PyInterpreterState **interp_p,

567565

*/

568566

_PyRuntime.finalizing = NULL;

569567570-

#ifndef MS_WINDOWS

571-

_emit_stderr_warning_for_legacy_locale(core_config);

572-

#endif

573-574568

err = _Py_HashRandomization_Init(core_config);

575569

if (_Py_INIT_FAILED(err)) {

576570

return err;

@@ -867,6 +861,11 @@ _Py_InitializeMainInterpreter(PyInterpreterState *interp,

867861

return err;

868862

}

869863

}

864+865+

#ifndef MS_WINDOWS

866+

_emit_stderr_warning_for_legacy_locale(core_config);

867+

#endif

868+870869

return _Py_INIT_OK();

871870

}

872871