This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients Mathis Hammel, mark.dickinson, rhettinger, tim.peters
Date 2019-05-23.15:47:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558626449.4.0.757565923506.issue37000@roundup.psfhosted.org>
In-reply-to
Content
Related:
    `randrange(0)` raises an exception
    `choice([])` raises an exception

Those are very different from `getrandbits(0)`: in both cases there's no reasonable value that can be returned: for the first case, there's no integer `x` with `0 <= x < 0`; for the second, there's no element of `[]`, period. In contrast, there's an obvious, valid, return value for `getrandbits(0)`.

The `getrandbits(0)` example is much more similar to `randrange(1)` (in fact, it's pretty much the same thing: apart from `n = 0`, `getrandbits(n)` is equivalent at some level to `randrange(2**n)`.

So if `getrandbits(0)` should be an exception on the basis of not having any randomness in the result, then `randrange(1)` should be an exception on the same basis, as should `random.uniform(2.0, 2.0)`, etc.

So to me, it makes no sense at all that `getrandbits(0)` raises: I can't see any good reason for it to do so.
History
Date User Action Args
2019-05-23 15:47:29mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, Mathis Hammel
2019-05-23 15:47:29mark.dickinsonsetmessageid: <1558626449.4.0.757565923506.issue37000@roundup.psfhosted.org>
2019-05-23 15:47:29mark.dickinsonlinkissue37000 messages
2019-05-23 15:47:29mark.dickinsoncreate