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

Reply via email to