[issue40388] random.choice integer overflow v3.5.2

2020-04-26 Thread Raymond Hettinger
Change by Raymond Hettinger : -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing

[issue40388] random.choice integer overflow v3.5.2

2020-04-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: Take your pick between either of these: random.randrange(1, N) random.randint(1, N-1) https://docs.python.org/3/library/random.html#functions-for-integers -- ___ Python tracker

[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

[issue40388] random.choice integer overflow v3.5.2

2020-04-25 Thread Mark Dickinson
Change by Mark Dickinson : -- resolution: -> not a bug status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing

[issue40388] random.choice integer overflow v3.5.2

2020-04-25 Thread Mark Dickinson
Mark Dickinson added the comment: I suspect that the OP is doing something like `random.choice(range(10**40))`: Python 3.8.2 (default, Feb 27 2020, 19:56:42) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin Type "help", "copyright", "credits" or "license" for more information.

[issue40388] random.choice integer overflow v3.5.2

2020-04-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: What you are describing is not what we mean by a crash (a core dump or segfault); it sounds like a regular Python exception. Python 3.5 is obsolete and there are no more bug fixes for it except for security fixes. You have not given us enough information

[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