mirror of https://github.com/python/cpython
[3.13] gh-121474: Add threading.Barrier parties arg sanity check. (GH-121480) (GH-122444)
(cherry picked from commit d27a53fc02
)
Co-authored-by: Clinton <pygeek@users.noreply.github.com>
This commit is contained in:
parent
466bb0d7ea
commit
202cfbfb7c
|
@ -1013,6 +1013,10 @@ class BarrierTests(BaseTestCase):
|
||||||
self.assertEqual(self.barrier.n_waiting, 0)
|
self.assertEqual(self.barrier.n_waiting, 0)
|
||||||
self.assertFalse(self.barrier.broken)
|
self.assertFalse(self.barrier.broken)
|
||||||
|
|
||||||
|
def test_constructor(self):
|
||||||
|
self.assertRaises(ValueError, self.barriertype, parties=0)
|
||||||
|
self.assertRaises(ValueError, self.barriertype, parties=-1)
|
||||||
|
|
||||||
def test_barrier(self, passes=1):
|
def test_barrier(self, passes=1):
|
||||||
"""
|
"""
|
||||||
Test that a barrier is passed in lockstep
|
Test that a barrier is passed in lockstep
|
||||||
|
|
|
@ -689,6 +689,8 @@ class Barrier:
|
||||||
default for all subsequent 'wait()' calls.
|
default for all subsequent 'wait()' calls.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if parties < 1:
|
||||||
|
raise ValueError("parties must be > 0")
|
||||||
self._cond = Condition(Lock())
|
self._cond = Condition(Lock())
|
||||||
self._action = action
|
self._action = action
|
||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix missing sanity check for ``parties`` arg in :class:`threading.Barrier`
|
||||||
|
constructor. Patch by Clinton Christian (pygeek).
|
Loading…
Reference in New Issue