https://github.com/unbit/uwsgi/commit/509104eaff6f6ecde656c20fdd65a0b98b371c8d From 509104eaff6f6ecde656c20fdd65a0b98b371c8d Mon Sep 17 00:00:00 2001 From: Nicolas Evrard Date: Thu, 17 Nov 2022 09:47:39 +0100 Subject: [PATCH] plugins/python: Use "backslashreplace" on stderr initialization Failing to use this value will result in enconding errors when logging unicode characters to stderr --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -554,7 +554,7 @@ void init_uwsgi_vars() { #ifdef HAS_NO_ERRORS_IN_PyFile_FromFd PyObject *new_stdprint = PyFile_FromFd(2, NULL, "w", _IOLBF, NULL, NULL, 0); #else - PyObject *new_stdprint = PyFile_FromFd(2, NULL, "w", _IOLBF, NULL, NULL, NULL, 0); + PyObject *new_stdprint = PyFile_FromFd(2, NULL, "w", _IOLBF, NULL, "backslashreplace", NULL, 0); #endif PyDict_SetItemString(pysys_dict, "stdout", new_stdprint); PyDict_SetItemString(pysys_dict, "__stdout__", new_stdprint);