Python 3 fix for the runtime.

pull/8/head
Dave Page 2018-02-19 16:30:43 +00:00
parent c85e14dc25
commit df667bff53
1 changed files with 6 additions and 0 deletions

View File

@ -210,7 +210,13 @@ Server::Server(quint16 port, QString key, QString logFileName)
// Redirect stderr
PyObject *sys = PyImport_ImportModule("sys");
#if PY_MINOR_VERSION > 2
FILE *log = fopen(m_logFileName.toUtf8().data(), (char *)"w");
int fd = fileno(log);
PyObject *err = PyFile_FromFd(fd, NULL, (char *)"w", -1, NULL, NULL, NULL, 0);
#else
PyObject *err = PyFile_FromString(m_logFileName.toUtf8().data(), (char *)"w");
#endif
PyObject_SetAttrString(sys, "stderr", err);
}