This assertion is caused by a workaround to set pythons encoding for
the stdout/stderr - r52739, to fix bug , the issue is reported on
Pythons bug tracker  but looks like a way around this won't be
available in a Python release any time soon.
Theres not much info available on how to change the encoding on a
running python interpreter and I couldn't find a way to stop this
assertion. If someone knows how then would be great, perhaps its
really simple but I tried restoring the previous stdout/stderr before
exiting, then removing the backup's (which hangs on exit). also
storing the backup files as members of the newly created file objects
(which does nothing).
As far as I can see the options are...
- remove the workaround and suffer bug [#31555]
- keep the workaround and suffer the assert().
- apply the patch to python that adds PyOS_PutEnv(), means rebuilding
python on all OS's.
- link python statically (apparently this way we'd be able to control
its env vars)
- start blender from a BAT-file/shell-script which sets the
environment variable from the parent process.
- use a C hack which modifies the encoding for stdout/stderr in-place
(error prone but may work).
- spend more time trying to find a workaround that doesn't assert.