summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-11-21 22:34:33 (GMT)
committerRaymond Hettinger <python@rcn.com>2016-11-21 22:34:33 (GMT)
commitbf87126a636bddf2d9a8f432215fe2efb98ba8fe (patch)
tree6d371582293e1813a6a1da1e2eabef361186cf0f /Lib/random.py
parent546ce65968921f52f1c79a7218e57dc237dbe436 (diff)
downloadcpython-bf87126a636bddf2d9a8f432215fe2efb98ba8fe.zip
cpython-bf87126a636bddf2d9a8f432215fe2efb98ba8fe.tar.gz
cpython-bf87126a636bddf2d9a8f432215fe2efb98ba8fe.tar.bz2
Issue 28475: Improve error message for random.sample() with k < 0. (Contributed by Francisco Couzo).
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/random.py b/Lib/random.py
index ca90e14..49b0f14 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -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: