[WIP] A workaround for Python 3.6 WindowsConsoleIO breaking with FDCapture by segevfiner · Pull Request #2462 · pytest-dev/pytest

@segevfiner

Python 3.6 implemented unicode console handling for Windows. This works
by reading/writing to the raw console handle using
``{Read,Write}ConsoleW``.

The problem is that we are going to ``dup2`` over the stdio file
descriptors when doing ``FDCapture`` and this will ``CloseHandle`` the
handles used by Python to write to the console. Though there is still some
weirdness and the console handle seems to only be closed randomly and not
on the first call to ``CloseHandle``, or maybe it gets reopened with the
same handle value when we suspend capturing.

The workaround in this case will reopen stdio with a different fd which
also means a different handle by replicating the logic in
"Py_lifecycle.c:initstdio/create_stdio".

See pytest-dev/py#103

RonnyPfannschmidt

approved these changes Jun 2, 2017

@segevfiner

@segevfiner

@segevfiner segevfiner deleted the py36-windowsconsoleio-workaround branch

June 4, 2017 04:27

prabhuramachandran added a commit to pypr/compyle that referenced this pull request

Feb 28, 2019
On Windows with Python >= 3.6.0, the console handling seems to have
changed and this seems to break our capturing the file descriptor to
suppress the compilation messages on the console.  pytest has a fix
here: pytest-dev/pytest#2462 but we essentially
do not do any capturing on windows for these Python versions as this fix
doesn't seem to help us here.  Hopefully this will be resolved in
Python itself at some point but for now this error was breaking any
compilation using compyle on Windows.