New GitHub issue #118961 from leikdga:<br>

<hr>

<pre>
# Feature or enhancement

### Proposal:

## Problem


In current [doc of random module](https://docs.python.org/3.14/library/random.html), it is mentioned that 

> Weights are assumed to be non-negative and finite. 

But what will happen if user violates this rule?

The program will just give strange result, which is also counter intuitive.

Here are some examples,

```python
from collections import Counter
import random

l = random.choices([1, 2, 3], weights=[2, -1, 1], k=1000)
print(Counter(l))  # Counter({3: 513, 1: 487})

l = random.choices([1, 2, 3], cum_weights=[2, float("inf"), 3], k=1000)
print(Counter(l))  # Counter({1: 658, 2: 342})

```

## Proposed Solution

We could explicitly raise an exception in such cases.



### Has this already been discussed elsewhere?

No response given

### Links to previous discussion of this feature:

_No response_
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/118961">View on GitHub</a>
<p>Labels: type-feature</p>
<p>Assignee: </p>