summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-29 20:56:06 (GMT)
committerGitHub <noreply@github.com>2018-08-29 20:56:06 (GMT)
commitcf21504194927b2f22132f48effea69eb8ade751 (patch)
tree40a239180bb186ad8a930c822a5540af0d367a74 /Python/pylifecycle.c
parent3d4226a832cabc630402589cc671cc4035d504e5 (diff)
downloadcpython-cf21504194927b2f22132f48effea69eb8ade751.zip
cpython-cf21504194927b2f22132f48effea69eb8ade751.tar.gz
cpython-cf21504194927b2f22132f48effea69eb8ade751.tar.bz2
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.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 6d97f2f..ad55b2c 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -301,10 +301,8 @@ static const char *_C_LOCALE_WARNING =
static void
_emit_stderr_warning_for_legacy_locale(const _PyCoreConfig *core_config)
{
- if (core_config->coerce_c_locale_warn) {
- if (_Py_LegacyLocaleDetected()) {
- fprintf(stderr, "%s", _C_LOCALE_WARNING);
- }
+ if (core_config->coerce_c_locale_warn && _Py_LegacyLocaleDetected()) {
+ PySys_FormatStderr("%s", _C_LOCALE_WARNING);
}
}
@@ -567,10 +565,6 @@ _Py_InitializeCore_impl(PyInterpreterState **interp_p,
*/
_PyRuntime.finalizing = NULL;
-#ifndef MS_WINDOWS
- _emit_stderr_warning_for_legacy_locale(core_config);
-#endif
-
err = _Py_HashRandomization_Init(core_config);
if (_Py_INIT_FAILED(err)) {
return err;
@@ -867,6 +861,11 @@ _Py_InitializeMainInterpreter(PyInterpreterState *interp,
return err;
}
}
+
+#ifndef MS_WINDOWS
+ _emit_stderr_warning_for_legacy_locale(core_config);
+#endif
+
return _Py_INIT_OK();
}