Title: Misleading error on random.sample when k < 0
Type: behavior Stage: patch review
Components: Documentation, Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: docs@python, franciscouzo, mark.dickinson, python-dev, rhettinger
Priority: normal Keywords: patch

Created on 2016-10-19 07:43 by franciscouzo, last changed 2016-11-21 22:37 by rhettinger. This issue is now closed.

File name Uploaded Description Edit
random_sample.patch franciscouzo, 2016-10-19 07:43 review
random_sample2.patch franciscouzo, 2016-10-19 20:55 review
Messages (4)
msg278964 - (view) Author: Francisco Couzo (franciscouzo) * Date: 2016-10-19 07:43
Improved a bit the error message when k < 0, and also added a comment about it on the documentation and an additional test case.
msg278992 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-10-19 20:49
I would rather revise the existing message to say that it cannot be negative or larger that population.
msg281400 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-11-21 22:35
New changeset 89f95c78e0ab by Raymond Hettinger in branch '3.6':
Issue 28475:  Improve error message for random.sample() with k < 0. (Contributed by Francisco Couzo).
msg281401 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-11-21 22:37
Thanks Franscisco.  

I ended-up not modifying the docs because I think it clutters that clarity with an irrelevant side issue.  The more important part was to make sure the error message wasn't misleading and the test that edge case.  I didn't backport to Python 2.7 because I don't think it meets the threshold of being interesting enough to warrant a backport to an old release.
Date User Action Args
2016-11-21 22:37:20rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg281401
2016-11-21 22:35:00python-devsetnosy: + python-dev
messages: + msg281400
2016-10-19 20:55:25franciscouzosetfiles: + random_sample2.patch
2016-10-19 20:49:02rhettingersetmessages: + msg278992
2016-10-19 07:58:19serhiy.storchakasetnosy: + rhettinger, mark.dickinson
versions: + Python 2.7, Python 3.5, Python 3.6, Python 3.7
assignee: docs@python -> rhettinger
components: - Tests
type: behavior
stage: patch review
2016-10-19 07:43:28franciscouzocreate