Commit 09473ac0 authored by Raymond Hettinger's avatar Raymond Hettinger Committed by GitHub

Remove unnecessary and over-restrictive type check (GH-10905)

parent b8e689a6
......@@ -718,8 +718,6 @@ class SystemRandom(Random):
"""getrandbits(k) -> x. Generates an int with k random bits."""
if k <= 0:
raise ValueError('number of bits must be greater than zero')
if k != int(k):
raise TypeError('number of bits should be an integer')
numbytes = (k + 7) // 8 # bits / 8 and rounded up
x = int.from_bytes(_urandom(numbytes), 'big')
return x >> (numbytes * 8 - k) # trim excess bits
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment