◐ Shell
clean mode source ↗

Message 197903 - Python tracker

The gory details of the current startup situation are in PEP 432. However, the comprehensive solution described in that PEP isn't going to make it into Python 3.4, so a simpler interim fix would be worthwhile.

Since Blender is designed to support building against the system Python, the trick of forcing Python to link to an alternate implementation of a function won't work.

Inspired by http://docs.python.org/3/c-api/init.html#Py_SetPath, I suggest offering an API like:

int Py_SetStandardStreamEncoding(char *encoding, char *errors)
{
    if (Py_IsInitialized()) {
        return -1;
    }
    Py_StandardStreamEncoding = _PyMem_Strdup(encoding);
    Py_StandardStreamErrors = _PyMem_Strdup(errors);
}

The initstdio function in pythonrun.c would then be updated to use the specified Py_StandardStreamEncoding and Py_StandardStreamErrors if they weren't NULL (since that would indicate an embedding application had called SetStandardStreamEncoding).