On 2020/05/07 16:17, Johan Corveleyn wrote:
> There is still the issue of PYTHONLEGACYWINDOWSSTDIO that is very much
> blocking for anyone running the testsuite on Windows with Python 3.
> Worst case, we might have to simply document it, and perhaps emit a
> warning if it's not set? Or can we simply set that envvar ourselves,
> automatically, from within some central place in the testsuite (as
> soon as redirection to a logfile has been requested or something)?
> Unless you still have some more magic up your sleeve to handle this,
> Yasuhito :-).
I created patch to resolve the issue of PYTHONLEGACYWINDOWSSTDIO and remove uses of os.dup2() in run_tests.py.
After attached patch, PYTHONLEGACYWINDOWSSTDIO is not needed.
(open_logfile): New function returning file-like object which is reassignable
sys.stdout and sys.stderr.
(TestHarness.run): Use open_logfile() instead of codecs.open().
(TestHarness._run_py_test): Reassign sys.stdout and sys.stderr instead of
uses of os.dup2().
(LoggingStdoutHandler): New function to use the value of sys.stdout at call
(parse_options): Use LoggingStdoutHandler() instead of
Tested with the following environments:
* Python 3.8.2 and Python 2.7.18 on Windows 10
* Python 3.8.2 on Linux
Jun Omae <jun66j5_at_gmail.com> (大前 潤)
Received on 2020-05-08 14:49:56 CEST