Skip to content

stdout/stderr mixup for implicit merge #2197

Description

@ewjoachim

Describe the bug
coverage json -o - outputs to stdout. But if there are multiple coverage files, it will first output a message in stdout meant for stderr (Combined 1 file) before ti outputs the json, which makes json parsing of stdout break.

To Reproduce
https://github.com/ewjoachim/test_cov
Execute the commands specified in the readme

Answer the questions below:

  1. What version of Python are you using?
    py3.14
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.1. What
-- sys -------------------------------------------------------
               coverage_version: 7.14.1
                coverage_module: /private/tmp/test_cov/.venv/lib/python3.14/site-packages/coverage/__init__.py
                           core: -none-
                        CTracer: available from /private/tmp/test_cov/.venv/lib/python3.14/site-packages/coverage/tracer.cpython-314-darwin.so
           plugins.file_tracers: -none-
            plugins.configurers: -none-
      plugins.context_switchers: -none-
              configs_attempted: /private/tmp/test_cov/.coveragerc
                                 /private/tmp/test_cov/.coveragerc.toml
                                 /private/tmp/test_cov/setup.cfg
                                 /private/tmp/test_cov/tox.ini
                                 /private/tmp/test_cov/pyproject.toml
                   configs_read: /private/tmp/test_cov/pyproject.toml
                    config_file: None
                config_contents: -none-
                      data_file: -none-
                         python: 3.14.2 (main, Jan 13 2026, 19:27:04) [Clang 21.1.4 ]
                       platform: macOS-26.2-arm64-arm-64bit-Mach-O
                 implementation: CPython
                          build: ('main', 'Jan 13 2026 19:27:04')
                    gil_enabled: True
                     executable: /private/tmp/test_cov/.venv/bin/python
                      pth_files: /private/tmp/test_cov/.venv/lib/python3.14/site-packages/a1_coverage.pth
                   def_encoding: utf-8
                    fs_encoding: utf-8
                            pid: 68734
                            cwd: /private/tmp/test_cov
                           path: /private/tmp/test_cov/.venv/bin
                                 /Users/joachim/.local/share/uv/python/cpython-3.14.2-macos-aarch64-none/lib/python314.zip
                                 /Users/joachim/.local/share/uv/python/cpython-3.14.2-macos-aarch64-none/lib/python3.14
                                 /Users/joachim/.local/share/uv/python/cpython-3.14.2-macos-aarch64-none/lib/python3.14/lib-dynload
                                 /private/tmp/test_cov/.venv/lib/python3.14/site-packages
                    environment: HOME = /Users/joachim
                                 PYTHONDONTWRITEBYTECODE = 1
                   command_line: /private/tmp/test_cov/.venv/bin/coverage debug sys
                           time: 2026-06-19 02:46:48
  1. versions of what packages do you have installed? The output of pip freeze is helpful.
    Nothing but coverage

  2. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.

https://github.com/ewjoachim/test_cov/commit/50774c34530788c696491a2d3c6aa17159812871

  1. What commands should we run to reproduce the problem? Be specific. Include everything, even git clone, pip install, and so on. Explain like we're five!
$ git clone https://github.com/ewjoachim/test_cov.git
$ uv run coverage run  hello.py
$ uv run coverage run --data-file=.coverage.2 hello.py
$ uv run coverage json -o -

Expected behavior

Only the json should be output by the last command.

Additional context
It's causing py-cov-action/python-coverage-comment-action#676

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions