The default encoding of sys.stdio and sys.stdout is determined by (in order of increasing precedence):
1. locale
2. PYTHONIOENCODING
3. Py_SetStandardStreamEncoding()
The default error handler before 3.5 was determined by:
1. 'strict'
2. PYTHONIOENCODING
3. Py_SetStandardStreamEncoding()
The default error handler since 3.5 (issue19977) is determined by:
1. PYTHONIOENCODING
2. locale
3. Py_SetStandardStreamEncoding()
Even if you explicitly specified the error handler by PYTHONIOENCODING, it doesn't have effect in POSIX locale. This doesn't look right to me. I think the order should be the same as for encoding.
Proposed patch makes PYTHONIOENCODING to override locale default for error handler. |