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 pitrou
Recipients mark.dickinson, pitrou, rhettinger, steven.daprano
Date 2020-04-14.15:32:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1586878355.33.0.583777817655.issue40282@roundup.psfhosted.org>
In-reply-to
Content
When creating variable-sized random binary strings with random.getrandbits(), you currently have to special case when the number of bytes is 0, because otherwise getrandbits() raises:

  ValueError: number of bits must be greater than zero

It seems like it wouldn't hurt to simply return 0 in that case.

The actual snippet looks something like:

  random.getrandombits(nbytes * 8).to_bytes(nbytes, 'little')
History
Date User Action Args
2020-04-14 15:32:35pitrousetrecipients: + pitrou, rhettinger, mark.dickinson, steven.daprano
2020-04-14 15:32:35pitrousetmessageid: <1586878355.33.0.583777817655.issue40282@roundup.psfhosted.org>
2020-04-14 15:32:35pitroulinkissue40282 messages
2020-04-14 15:32:35pitroucreate