[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Chris Tandiono
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 fo

[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: A negative value will almost never be the cause of this exception. The proposed new message is more accurate but is also less useful and informative. Getting a ValueError exception already means "the value is invalid". The job of the message is to suggest

[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- Removed message: http://bugs.python.org/msg183836 ___ Python tracker ___ ___ Python-bugs-list mailin

[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: This seems like a silly criticism to me. A negative value will almost never be the cause of this exception. That said, I'll tweak the message at some point. -- assignee: -> rhettinger priority: normal -> low __

[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Ned Deily
Changes by Ned Deily : -- nosy: +mark.dickinson, rhettinger versions: -3rd party, Python 2.6, Python 3.1, Python 3.5 ___ Python tracker ___ _

[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Chris Tandiono
Changes by Chris Tandiono : -- title: Providing invalid value to -> Providing invalid value to random.sample can result in incorrect error message ___ Python tracker ___ ___

[issue17388] Providing invalid value to

2013-03-09 Thread Chris Tandiono
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 p