Message367271
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.
>>> import random
>>> random.choice(range(10**40))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/random.py", line 288, in choice
i = self._randbelow(len(seq))
OverflowError: Python int too large to convert to C ssize_t
The advice in this case would be to use something like random.randrange(10**40) instead.
The actual bug here, if there is a bug, has nothing to do with random, but instead has to do with "virtual" sequences whose length exceeds 2**63 - 1. There are other issues in the tracker for this, for example issue 12159.
I suggest closing as "not a bug". |
|
Date |
User |
Action |
Args |
2020-04-25 10:17:10 | mark.dickinson | set | recipients:
+ mark.dickinson, steven.daprano, dev00790 |
2020-04-25 10:17:10 | mark.dickinson | set | messageid: <1587809830.31.0.0423585443559.issue40388@roundup.psfhosted.org> |
2020-04-25 10:17:10 | mark.dickinson | link | issue40388 messages |
2020-04-25 10:17:10 | mark.dickinson | create | |
|