Skip to content

gh-158234: Fix _compare_grouped_stats mutating old_group and a typo - #158233

Open
Tony123-tech wants to merge 1 commit into
python:mainfrom
Tony123-tech:gh-158232-fix-tracemalloc-compare-grouped-stats
Open

Tony123-tech wants to merge 1 commit into
python:mainfrom
Tony123-tech:gh-158232-fix-tracemalloc-compare-grouped-stats

Conversation

@Tony123-tech

@Tony123-tech Tony123-tech commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Two small issues in Lib/tracemalloc.py:

  1. _compare_grouped_stats() mutates its old_group argument by popping
    keys from it. After the call, old_group is missing every key that
    was also in new_group. The current caller (Snapshot.compare_to)
    does not reuse the dict, so the bug is latent, but the function
    should not modify its arguments. Fix: copy the dict at the top.

  2. A typo in the error message raised by _group_by():
    "cumulative mode cannot by used" should be
    "cumulative mode cannot be used".

No NEWS entry needed: neither change is user-visible.

@bedevere-app

bedevere-app Bot commented Sep 26, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@Tony123-tech

Copy link
Copy Markdown
Contributor Author

No NEWS entry needed: neither change is user-visible. The
_compare_grouped_stats fix affects a private function, and the typo
fix only changes an error message.

@Tony123-tech Tony123-tech changed the title gh-158232: Fix _compare_grouped_stats mutating old_group and a typo gh-158234: Fix _compare_grouped_stats mutating old_group and a typo Sep 26, 2026
@python python locked and limited conversation to collaborators Sep 27, 2026
@python python unlocked this conversation Sep 27, 2026
@picnixz picnixz closed this Sep 27, 2026
@picnixz picnixz reopened this Sep 27, 2026
@Tony123-tech

Copy link
Copy Markdown
Contributor Author

The typo fix is user-visible only in the sense that the error message
changes. I don't think a NEWS entry is needed. Let me know if you
disagree.

@Tony123-tech
Tony123-tech force-pushed the gh-158232-fix-tracemalloc-compare-grouped-stats branch from be75241 to efe7bd4 Compare September 27, 2026 04:47
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.

2 participants