Details
Description
After the changes in https://codereview.qt-project.org/gitweb?p=pyside/pyside-setup.git;a=commitdiff;h=43fe3494a9d902034896e3afa7b5158c77163be0;hp=c6c9f057cddc0e0b885a648489264538eba0a158
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
Prerequisites:
LC_CTYPE (or LC_ALL) is POSIX aka C, or any other non-UTF8 locale
-> setuptools/dist.py calls detach() on sys.stdout in handle_display_options if sys.stdout.encoding.lower() in ('utf-8', 'utf8'): return _Distribution.handle_display_options(self, option_order) ... sys.stdout = io.TextIOWrapper( sys.stdout.detach(), 'utf-8', errors, newline, line_buffering)
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:
elif stderr == STDOUT: if c2pwrite != -1: errwrite = c2pwrite else: # child's stdout is not set, use parent's stdout errwrite = sys.__stdout__.fileno()
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.
Attachments
For Gerrit Dashboard: PYSIDE-880 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
248993,3 | setup.py: Fix running under non-UTF8 locale | 5.12 | pyside/pyside-setup | Status: MERGED | +2 | 0 |