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

This commit is contained in:
jonanifranco 2021-01-18 19:04:29 +01:00 committed by GitHub
parent 314b8787e0
commit f7b5bacd7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 28 deletions

View file

@ -479,7 +479,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