bpo-42944 Fix Random.sample when counts is not None (GH-24235) (GH-24243)

This commit is contained in:
Miss Islington (bot) 2021-01-18 10:36:07 -08:00 committed by GitHub
parent 799722cb0d
commit a90539f572
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 28 deletions

View file

@ -442,7 +442,7 @@ class Random(_random.Random):
raise TypeError('Counts must be integers')
if total <= 0:
raise ValueError('Total of counts must be greater than zero')
selections = sample(range(total), k=k)
selections = self.sample(range(total), k=k)
bisect = _bisect
return [population[bisect(cum_counts, s)] for s in selections]
randbelow = self._randbelow