Skip to content

Conversation

@cmaloney
Copy link
Contributor

@cmaloney cmaloney commented Oct 14, 2025

libregrtest redirects test output to a file as part of its operation. When unittest checks to see if it should colorize with isatty(sys.stdout) that returns False resulting in no colorizing of the unittest output.

Update libregrtest to set FORCE_COLOR=1 when redirecting test output so that unittest will do color printing.

libregrtest redirects test output to a file as part of its operation.
When `unittest` checks to see if it should colorize with
`isatty(sys.stdout)` that fails resulting in no colorizing of the
unittest output.

Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output
so that unittest will do color printing.
@cmaloney
Copy link
Contributor Author

I think this can be skip news as it's a strictly internal change / libregrtest isn't externally exposed

@vstinner
Copy link
Member

You might add a NEWS entry in the Tests category.

Co-authored-by: Victor Stinner <[email protected]>
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please add requested comment :-)

@vstinner vstinner merged commit 6ff62ac into python:main Oct 29, 2025
54 checks passed
@vstinner vstinner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Oct 29, 2025
@miss-islington-app
Copy link

Thanks @cmaloney for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @cmaloney for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 29, 2025
…honGH-140083)

libregrtest redirects test output to a file as part of its operation.
When `unittest` checks to see if it should colorize with
`isatty(sys.stdout)` that fails resulting in no colorizing of the
unittest output.

Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output
so that unittest will do color printing.
(cherry picked from commit 6ff62ac)

Co-authored-by: Cody Maloney <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 29, 2025
…honGH-140083)

libregrtest redirects test output to a file as part of its operation.
When `unittest` checks to see if it should colorize with
`isatty(sys.stdout)` that fails resulting in no colorizing of the
unittest output.

Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output
so that unittest will do color printing.
(cherry picked from commit 6ff62ac)

Co-authored-by: Cody Maloney <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Oct 29, 2025

GH-140755 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Oct 29, 2025
@bedevere-app
Copy link

bedevere-app bot commented Oct 29, 2025

GH-140756 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Oct 29, 2025
@vstinner
Copy link
Member

Merged, thanks for your contribution!

vstinner added a commit that referenced this pull request Oct 29, 2025
…-140083) (#140755)

gh-140082: Forward colorizing from libregrtest to unittest (GH-140083)

libregrtest redirects test output to a file as part of its operation.
When `unittest` checks to see if it should colorize with
`isatty(sys.stdout)` that fails resulting in no colorizing of the
unittest output.

Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output
so that unittest will do color printing.
(cherry picked from commit 6ff62ac)

Co-authored-by: Cody Maloney <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot x86-64 MacOS Intel NoGIL 3.x (tier-2) has failed when building commit 6ff62ac.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1258/builds/6081) and take a look at the build logs.
  4. Check if the failure is related to this commit (6ff62ac) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1258/builds/6081

Failed tests:

  • test_profiling

Failed subtests:

  • test_script_error_treatment - test.test_profiling.test_sampling_profiler.TestSampleProfilerErrorHandling.test_script_error_treatment

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/test/test_profiling/test_sampling_profiler.py", line 2097, in test_script_error_treatment
    self.assertIn("No such file or directory: 'nonexistent_file.txt'", output)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: "No such file or directory: 'nonexistent_file.txt'" not found in 'Traceback (most recent call last):\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/runpy.py", line 198, in _run_module_as_main\n    return _run_code(code, main_globals, None,\n                     "__main__", mod_spec)\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/runpy.py", line 88, in _run_code\n    exec(code, run_globals)\n    ~~~~^^^^^^^^^^^^^^^^^^^\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 941, in <module>\n    main()\n    ~~~~^^\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 930, in main\n    wait_for_process_and_sample(process.pid, sort_value, args)\n    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 697, in wait_for_process_and_sample\n    sample(\n    ~~~~~~^\n        pid,\n        ^^^^\n    ...<9 lines>...\n        mode=mode,\n        ^^^^^^^^^^\n    )\n    ^\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 617, in sample\n    profiler = SampleProfiler(\n        pid, sample_interval_usec, all_threads=all_threads, mode=mode\n    )\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 144, in __init__\n    self.unwinder = _remote_debugging.RemoteUnwinder(\n                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n        self.pid, all_threads=self.all_threads, mode=mode\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    )\n    ^\nPermissionError: Cannot get task port for PID 93644 (kern_return_t: 5). This typically requires running as root or having the \'com.apple.system-task-ports\' entitlement.\n'


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/test/test_profiling/test_sampling_profiler.py", line 2097, in test_script_error_treatment
    self.assertIn("No such file or directory: 'nonexistent_file.txt'", output)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: "No such file or directory: 'nonexistent_file.txt'" not found in 'Traceback (most recent call last):\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/runpy.py", line 198, in _run_module_as_main\n    return _run_code(code, main_globals, None,\n                     "__main__", mod_spec)\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/runpy.py", line 88, in _run_code\n    exec(code, run_globals)\n    ~~~~^^^^^^^^^^^^^^^^^^^\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 941, in <module>\n    main()\n    ~~~~^^\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 930, in main\n    wait_for_process_and_sample(process.pid, sort_value, args)\n    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 697, in wait_for_process_and_sample\n    sample(\n    ~~~~~~^\n        pid,\n        ^^^^\n    ...<9 lines>...\n        mode=mode,\n        ^^^^^^^^^^\n    )\n    ^\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 617, in sample\n    profiler = SampleProfiler(\n        pid, sample_interval_usec, all_threads=all_threads, mode=mode\n    )\n  File "/Users/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/profiling/sampling/sample.py", line 144, in __init__\n    self.unwinder = _remote_debugging.RemoteUnwinder(\n                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n        self.pid, all_threads=self.all_threads, mode=mode\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    )\n    ^\nPermissionError: Cannot get task port for PID 91936 (kern_return_t: 5). This typically requires running as root or having the \'com.apple.system-task-ports\' entitlement.\n'

@cmaloney cmaloney deleted the libregrtest_color_unittest branch October 29, 2025 17:45
@cmaloney
Copy link
Contributor Author

Failure seems to be independent:

PermissionError: Cannot get task port for PID 93644 (kern_return_t: 5). This typically requires running as root or having the \'com.apple.system-task-ports\' entitlement.\n'

vstinner added a commit that referenced this pull request Oct 29, 2025
…-140083) (#140756)

gh-140082: Forward colorizing from libregrtest to unittest (GH-140083)

libregrtest redirects test output to a file as part of its operation.
When `unittest` checks to see if it should colorize with
`isatty(sys.stdout)` that fails resulting in no colorizing of the
unittest output.

Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output
so that unittest will do color printing.
(cherry picked from commit 6ff62ac)

Co-authored-by: Cody Maloney <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD Refleaks 3.14 (tier-3) has failed when building commit 0779ef9.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1800/builds/621) and take a look at the build logs.
  4. Check if the failure is related to this commit (0779ef9) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1800/builds/621

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/buildbot/buildarea/3.14.ware-freebsd.refleak/build/Lib/test/support/__init__.py", line 847, in gc_collect
    gc.collect()
ResourceWarning: unclosed <socket.socket fd=8, family=2, type=1, proto=6, laddr=('127.0.0.1', 44989), raddr=('127.0.0.1', 44990)>
Task was destroyed but it is pending!
task: <Task pending name='Task-2435' coro=<BaseSelectorEventLoop._accept_connection2() done, defined at /buildbot/buildarea/3.14.ware-freebsd.refleak/build/Lib/asyncio/selector_events.py:217> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Warning -- Unraisable exception
Exception ignored while calling deallocator <function _SelectorTransport.__del__ at 0x8456bbd10>:
Traceback (most recent call last):
  File "/buildbot/buildarea/3.14.ware-freebsd.refleak/build/Lib/asyncio/selector_events.py", line 873, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: unclosed transport <_SelectorSocketTransport closing fd=8>
k


Traceback (most recent call last):
  File "/buildbot/buildarea/3.14.ware-freebsd.refleak/build/Lib/test/support/__init__.py", line 847, in gc_collect
    gc.collect()
ResourceWarning: unclosed <socket.socket fd=9, family=2, type=1, proto=6, laddr=('127.0.0.1', 46353), raddr=('127.0.0.1', 46354)>
Task was destroyed but it is pending!
task: <Task pending name='Task-1267' coro=<BaseSelectorEventLoop._accept_connection2() done, defined at /buildbot/buildarea/3.14.ware-freebsd.refleak/build/Lib/asyncio/selector_events.py:217> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Warning -- Unraisable exception
Exception ignored while calling deallocator <function _SelectorTransport.__del__ at 0x8408abd10>:
Traceback (most recent call last):
  File "/buildbot/buildarea/3.14.ware-freebsd.refleak/build/Lib/asyncio/selector_events.py", line 873, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: unclosed transport <_SelectorSocketTransport closing fd=9>
k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants