python / python/cpython

Tachyon's `pstats_collector` does not respect "no-color" modes

Open
#154,335 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-profiling type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

The Tachyon sampling profiler always emits colored output when used with the pstats collector. For example, the NO_COLOR environment variable is currently not respected:

NO_COLOR=1 python -m profiling.sampling run --pstats test.py

Enabling this would be useful e.g. in cases where the output is redirected into a file for further processing, as it avoids including ANSI escape sequences in the file.

There is already a helper function available in the project that could be used to enable this functionality:
https://github.com/python/cpython/blob/main/Lib/_colorize.py#L564-L605

If you think this would be a useful addition/fix, I'd be happy to work on a patch PR.

Best, Peter

CPython versions tested on:

3.15

Operating systems tested on:

No response

Linked PRs
  • gh-154344

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the python -m profiling.sampling run --pstats test.py entry point and inspect the color-handling helper in Lib/_colorize.py. Verify the pstats collector respects NO_COLOR=1 and that redirected output contains no ANSI escape sequences.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.