[issue42846] Using _multibytecodec module on Windows, test_threading/embed get failure

STINNER Victor report at bugs.python.org
Thu Jan 7 18:08:48 EST 2021


STINNER Victor <vstinner at python.org> added the comment:

Simpler way to reproduce the issue with t.py script:
---
import test.support
import sys

import _testcapi

print(f"{sys.stdout.encoding=}", file=sys.stderr)

with test.support.SuppressCrashReport():
    _testcapi.run_in_subinterp("pass")
---

By default, UTF-8 is used, everything is fine:
-----
C:\> python t.py
sys.stdout.encoding='utf-8'
-----

Disable _WindowsConsoleIO with PYTHONLEGACYWINDOWSSTDIO env var, we get the issue:
-----
C:\> set PYTHONLEGACYWINDOWSSTDIO=1

C:\> python t.py
Running Debug|x64 interpreter...
sys.stdout.encoding='cp932'
TypeError: codec is unexpected type
Fatal Python error: (...)
-----

Or redirect the output into a program or a file to disable _WindowsConsoleIO to also reproduce the issue:
-----
C:\> python t.py|more
sys.stdout.encoding='cp932'
TypeError: codec is unexpected type
(...)
-----

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42846>
_______________________________________


More information about the Python-bugs-list mailing list