diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 9a429026..e2ad57fe 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -500,7 +500,11 @@ void init_uwsgi_vars() { #ifdef PYTHREE // fix stdout and stderr - PyObject *new_stdprint = PyFile_NewStdPrinter(2); +#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); +#endif PyDict_SetItemString(pysys_dict, "stdout", new_stdprint); PyDict_SetItemString(pysys_dict, "__stdout__", new_stdprint); PyDict_SetItemString(pysys_dict, "stderr", new_stdprint); diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index a10a5b2c..0de1348d 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -22,6 +22,10 @@ #define HAS_NOT_PyFrame_GetLineNumber #endif +#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0 +#define HAS_NO_ERRORS_IN_PyFile_FromFd +#endif + #if PY_MAJOR_VERSION > 2 #define PYTHREE #endif