diff -r 884c9d9159dc Doc/library/random.rst --- a/Doc/library/random.rst Wed Oct 19 19:38:22 2016 +0300 +++ b/Doc/library/random.rst Wed Oct 19 17:53:31 2016 -0300 @@ -179,8 +179,8 @@ argument. This is especially fast and space efficient for sampling from a large population: ``sample(range(10000000), 60)``. - If the sample size is larger than the population size, a :exc:`ValueError` - is raised. + If the sample size is negative or larger than the population size, a + :exc:`ValueError` is raised. The following functions generate specific real-valued distributions. Function parameters are named after the corresponding variables in the distribution's diff -r 884c9d9159dc Lib/random.py --- a/Lib/random.py Wed Oct 19 19:38:22 2016 +0300 +++ b/Lib/random.py Wed Oct 19 17:53:31 2016 -0300 @@ -314,7 +314,7 @@ randbelow = self._randbelow n = len(population) if not 0 <= k <= n: - raise ValueError("Sample larger than population") + raise ValueError("Sample negative or larger than population") result = [None] * k setsize = 21 # size of a small set minus size of an empty list if k > 5: diff -r 884c9d9159dc Lib/test/test_random.py --- a/Lib/test/test_random.py Wed Oct 19 19:38:22 2016 +0300 +++ b/Lib/test/test_random.py Wed Oct 19 17:53:31 2016 -0300 @@ -110,6 +110,7 @@ self.assertEqual(self.gen.sample([], 0), []) # test edge case N==k==0 # Exception raised if size of sample exceeds that of population self.assertRaises(ValueError, self.gen.sample, population, N+1) + self.assertRaises(ValueError, self.gen.sample, [], -1) def test_sample_distribution(self): # For the entire allowable range of 0 <= k <= N, validate that