run_process() from build_scripts/utils.py may fail in the nested invocation, e.g. for
/usr/bin/python3 setup.py build --reuse-build --ignore-git --internal-build-type=shiboken2
LC_CTYPE (or LC_ALL) is POSIX aka C, or any other non-UTF8 locale
Afterwards, sys.stdout is valid, but sys._stdout_ no longer is.
subprocess tries to reassign STDERR to STDOUT (see _get_handles()), as run_process called from build_extension() uses kwargs['stderr'] = subprocess.STDOUT, but fails:
c2pwrite is -1, sys._stdout_ is detached, see https://docs.python.org/3/library/io.html#io.BufferedIOBase
One possible workaround is to use set LC_ALL=C.utf8.