[issue33203] random.choice: raise IndexError on empty sequence even when not using getrandbits internally

Wolfgang Maier report at bugs.python.org
Tue Apr 3 04:50:00 EDT 2018


Wolfgang Maier <wolfgang.maier at biologie.uni-freiburg.de> added the comment:

@selik: it's true _randbelow doesn't work for negative numbers, but the difference is that both branches are affected, the docstring does not make any guarantees about it, and no public part of the random module is affected by this behavior. In addition, "fixing" _randbelow for negative input cannot be done without impacting performance of several public methods of random.Random so I don't think this should be done.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33203>
_______________________________________


More information about the Python-bugs-list mailing list