mirror of
https://github.com/python/cpython.git
synced 2025-10-07 23:51:16 +00:00
Issue 28475: Improve error message for random.sample() with k < 0. (Contributed by Francisco Couzo).
This commit is contained in:
parent
546ce65968
commit
bf87126a63
2 changed files with 2 additions and 1 deletions
|
@ -314,7 +314,7 @@ class Random(_random.Random):
|
|||
randbelow = self._randbelow
|
||||
n = len(population)
|
||||
if not 0 <= k <= n:
|
||||
raise ValueError("Sample larger than population")
|
||||
raise ValueError("Sample larger than population or is negative")
|
||||
result = [None] * k
|
||||
setsize = 21 # size of a small set minus size of an empty list
|
||||
if k > 5:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue