You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
trace: --count --no-report --file does not save the counts file #152409
python -m trace --count --no-report --file FILE script.py exits
successfully but never writes FILE, so counts cannot be accumulated
across runs.
Both options are documented for exactly this workflow:
-f, --file FILE — "File to accumulate counts over several runs"
-R, --no-report — "Do not generate the coverage report files. Useful
if you want to accumulate over several runs."
and Doc/library/trace.rst describes --no-report as useful when you
"intend to make several runs with --count, and then produce a single
set of annotated listings at the end."
However the counts are only persisted at the end of CoverageResults.write_results(), which main() skips entirely under --no-report:
So --no-report suppresses the report and the --file counts. The file
is never created, and because --file is also read back at startup, every
run warns about the file it was supposed to accumulate into:
$ cat prog.py
for i in range(3):
pass
$ python -m trace --count --no-report --file counts prog.py
Skipping counts file 'counts': [Errno 2] No such file or directory: 'counts'
$ python -m trace --count --no-report --file counts prog.py
Skipping counts file 'counts': [Errno 2] No such file or directory: 'counts'
counts is never written, so accumulation never happens. The same command without--no-report does write counts (alongside the .cover report).
Suggested fix
Move the counts-saving step out of write_results() into a small CoverageResults.save_counts() helper and call it on the --no-report
path as well, so --file is honoured regardless of --no-report.
Originally, saving the report and counts was independent. It was broken in a30eacf (bpo-476866/gh-35437) after merging both in write_results(). This change looks not deliberate to me.
Activity
sap6011 commentedon Jun 27, 2026
sergey-miryanov commentedon Jun 27, 2026
sap6011 commentedon Jun 27, 2026
serhiy-storchaka commentedon Aug 17, 2026
Originally, saving the report and counts was independent. It was broken in a30eacf (bpo-476866/gh-35437) after merging both in
write_results(). This change looks not deliberate to me.cc @zooko, @gvanrossum, @smontanaro
gh-152409: Save the trace --file counts when --no-report is used (GH-…