[issue40388] random.choice integer overflow v3.5.2

2020-04-25 Thread Nicholas Prowse


New submission from Nicholas Prowse :

Filename: random.py
Location of file: /use/lib/python3.5/random.py
Function: random.choice()
Input: 40 digit integer
Expected output: no crash
Actual output: Crash
Line number: 253
Error message: "Python int too large to convert to C ssize_t"

Traceback:
a = random.choice(sequence)
i= self._randbelow(len(seq))

Error occurs on last line 253.

--
components: Library (Lib)
messages: 367266
nosy: dev00790
priority: normal
severity: normal
status: open
title: random.choice integer overflow v3.5.2
type: crash
versions: Python 3.5

___
Python tracker 
<https://bugs.python.org/issue40388>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40388] random.choice integer overflow v3.5.2

2020-04-25 Thread Nicholas Prowse


Nicholas Prowse  added the comment:

Code as requested is similar to the below:

N = <40 digit int>
sequence=range(1,N)
a = random.choice(sequence)

Since you class the error previously mentioned as an exception, what function 
should be used instead for choosing a random integer between 1 and including 
N-1?

--
status: pending -> open

___
Python tracker 
<https://bugs.python.org/issue40388>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com