Skip to content

bpo-45410: regrtest -W leaves stdout/err FD unchanged #28915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 13, 2021
Merged

bpo-45410: regrtest -W leaves stdout/err FD unchanged #28915

merged 2 commits into from
Oct 13, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 13, 2021

libregrtest capture_std_streams() no longer replaces stdout and
stderr file descriptors.

libregrtest now always call faulthandler.enable() with file=2. Don't
attempt to get the file descriptor from sys.stderr.

Remove also a few unused imports in libregrtest.

https://bugs.python.org/issue45410

@vstinner
Copy link
Member Author

fileno() is expected to work on sys.__stdout__ and sys.__stderr__. I need to revert my change: use a temporary file.

  File "/home/runner/work/cpython/cpython/Lib/test/test_shutil.py", line 2606, in TestGetTerminalSize
    @unittest.skipUnless(os.isatty(sys.__stdout__.fileno()), "not on tty")
                                   ^^^^^^^^^^^^^^^^^^^^^^^

and:

ERROR: test_select_mutated (test.test_select.SelectTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython/Lib/test/test_select.py", line 88, in test_select_mutated
    self.assertEqual(select.select([], a, []), ([], a[:5], []))
                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/cpython/cpython/Lib/test/test_select.py", line 86, in fileno
    return sys.__stdout__.fileno()
           ^^^^^^^^^^^^^^^^^^^^^^^
io.UnsupportedOperation: fileno

support.print_warning() now stores the original value of
sys.__stderr__ and uses it to log warnings. libregrtest uses the same
stream to log unraisable exceptions and uncaught threading
exceptions.

Partially revert commit dbe213d:
libregrtest no longer replaces sys.__stdout__, sys.__stderr__, and
stdout and stderr file descriptors.

Remove also a few unused imports in libregrtest.
@vstinner vstinner merged commit 7733307 into python:main Oct 13, 2021
@vstinner vstinner deleted the regrtest_stderr branch October 13, 2021 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants