[issue17388] Providing invalid value to
New submission from Chris Tandiono: Currently, random.sample(population, k) raises a ValueError if k is out of the range of [0, len(population)], inclusive. However, the message says Sample larger than population even when the real problem is that k 0. The attached patch fixes that. The problem exists in all versions of Python that have the random.sample function. I think I should be adding tests for this, but I don't know in what existing file, if any, this test should go into. -- components: Library (Lib) files: random_sample.patch keywords: patch messages: 183808 nosy: Chris.Tandiono priority: normal severity: normal status: open title: Providing invalid value to type: behavior versions: 3rd party, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file29354/random_sample.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17388 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17388] Providing invalid value to random.sample can result in incorrect error message
Changes by Chris Tandiono chris.tandi...@gmail.com: -- title: Providing invalid value to - Providing invalid value to random.sample can result in incorrect error message ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17388 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17388] Providing invalid value to random.sample can result in incorrect error message
Chris Tandiono added the comment: Hmm. I'm not sure I buy the argument that the new message is less useful (wouldn't you like to know the exact values that caused the problem? that's what int() does when you provide it garbage). I guess it could be less informative, since you have to decide for yourself whether it's too large or too small a value. At any rate, I think that whatever modification(s) you make to the message, it shouldn't say Sample larger than population when k 0, because that's just plain misleading. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17388 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com