Bug report
Bug description:
random.Random()._randbelow_with_getrandbits(0) # loops indefinitely
Same applies to (conditional) synonym ._randbelow().
Note the alternative implementation (below) fails:
random.Random()._randbelow_without_getrandbits(0) # raises ZeroDivisionError
I suggest adding a check on lower bound (like _randbelow_without_getrandbits has on upper bound).
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Same applies to (conditional) synonym
._randbelow().Note the alternative implementation (below) fails:
I suggest adding a check on lower bound (like
_randbelow_without_getrandbitshas on upper bound).CPython versions tested on:
3.14
Operating systems tested on:
Windows