]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove unnecessary and over-restrictive type check (GH-10905)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 4 Dec 2018 22:53:14 +0000 (14:53 -0800)
committerGitHub <noreply@github.com>
Tue, 4 Dec 2018 22:53:14 +0000 (14:53 -0800)
Lib/random.py

index a7a86070c0a912c5c9b1b22d816b9d7196aa0cb7..03c058a39d6e1e2598afd6bf3f9ff40e9de92e9b 100644 (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