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

This commit is contained in:
Raymond Hettinger 2018-12-04 14:53:14 -08:00 committed by GitHub
parent b8e689a6e8
commit 09473ac063
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 2 deletions

View File

@ -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