]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-150175: Fix ThreadingMock call_count race condition (#150176)
authorsaisneha196 <156835592+saisneha196@users.noreply.github.com>
Thu, 21 May 2026 07:38:07 +0000 (13:08 +0530)
committerGitHub <noreply@github.com>
Thu, 21 May 2026 07:38:07 +0000 (08:38 +0100)
commit388e023fe1197c1ffed374520ed45df4ac72b8f5
tree0c32bac2e4efe0d0c257811d548fb4dde541bc6e
parentcb3b4b98d8d141c9de0462a0fa7e227a2104c1c7
gh-150175: Fix ThreadingMock call_count race condition (#150176)

ThreadingMock._increment_mock_call() was not thread-safe.
Multiple threads calling the mock simultaneously could lose
increments due to race conditions on call_count and other
attributes.

Fix by overriding _increment_mock_call in ThreadingMixin
and wrapping it with the existing _mock_calls_events_lock.
Lib/unittest/mock.py
Misc/NEWS.d/next/Library/2026-05-21-11-25-58.gh-issue-150175.8H4Caz.rst [new file with mode: 0644]