Skip to content

gh-153141: Fix mutable default argument in _SharedMemoryTracker.__init__#153142

Merged
gpshead merged 1 commit into
python:mainfrom
whyvineet:fix-sharedmemorytracker-default-list
Jul 5, 2026
Merged

gh-153141: Fix mutable default argument in _SharedMemoryTracker.__init__#153142
gpshead merged 1 commit into
python:mainfrom
whyvineet:fix-sharedmemorytracker-default-list

Conversation

@whyvineet

@whyvineet whyvineet commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace the mutable default argument (segment_names=[]) in _SharedMemoryTracker.__init__ with None to avoid unintended shared state between instances.

Fixes: #153141

@whyvineet whyvineet requested a review from gpshead as a code owner July 5, 2026 18:01
@gpshead gpshead self-assigned this Jul 5, 2026
@gpshead gpshead added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news labels Jul 5, 2026
@gpshead

gpshead commented Jul 5, 2026

Copy link
Copy Markdown
Member

skip news added - i'm not bothering with a news entry as this is a trivial invisible to users internal cleanup.

@gpshead gpshead enabled auto-merge (squash) July 5, 2026 18:38
@gpshead gpshead merged commit d733b10 into python:main Jul 5, 2026
96 of 99 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @whyvineet for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app

bedevere-app Bot commented Jul 5, 2026

Copy link
Copy Markdown

GH-153145 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 5, 2026
@bedevere-app

bedevere-app Bot commented Jul 5, 2026

Copy link
Copy Markdown

GH-153146 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 Jul 5, 2026
@bedevere-app

bedevere-app Bot commented Jul 5, 2026

Copy link
Copy Markdown

GH-153147 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 Jul 5, 2026
gpshead pushed a commit that referenced this pull request Jul 5, 2026
…r.__init__ (GH-153142) (#153146)

gh-153141: Fix mutable default argument in _SharedMemoryTracker.__init__ (GH-153142)

Fix default argument for segment_names in _SharedMemoryTracker constructor to not use a mutable list.
(cherry picked from commit d733b10)

Co-authored-by: Vineet Kumar <108144301+whyvineet@users.noreply.github.com>
gpshead pushed a commit that referenced this pull request Jul 5, 2026
…r.__init__ (GH-153142) (#153147)

gh-153141: Fix mutable default argument in _SharedMemoryTracker.__init__ (GH-153142)

Fix default argument for segment_names in _SharedMemoryTracker constructor to not use a mutable list.
(cherry picked from commit d733b10)

Co-authored-by: Vineet Kumar <108144301+whyvineet@users.noreply.github.com>
gpshead pushed a commit that referenced this pull request Jul 5, 2026
…r.__init__ (GH-153142) (#153145)

gh-153141: Fix mutable default argument in _SharedMemoryTracker.__init__ (GH-153142)

Fix default argument for segment_names in _SharedMemoryTracker constructor to not use a mutable list.
(cherry picked from commit d733b10)

Co-authored-by: Vineet Kumar <108144301+whyvineet@users.noreply.github.com>
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.

Mutable default argument in _SharedMemoryTracker.__init__ causes shared state between instances

2 participants