summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2021-09-20 18:22:55 (GMT)
committerGitHub <noreply@github.com>2021-09-20 18:22:55 (GMT)
commit9510e6f3c797b4398aaf58abc1072b9db0a644f9 (patch)
tree02cc57a588d356766df4bd191430c7cbdeca5a18 /Lib/random.py
parent5846c9b71ee9277fe866b1bdee4cc6702323fe7e (diff)
downloadcpython-9510e6f3c797b4398aaf58abc1072b9db0a644f9.zip
cpython-9510e6f3c797b4398aaf58abc1072b9db0a644f9.tar.gz
cpython-9510e6f3c797b4398aaf58abc1072b9db0a644f9.tar.bz2
bpo-45155: Apply new byteorder default values for int.to/from_bytes (GH-28465)
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 38c4a54..3569d58 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -154,7 +154,7 @@ class Random(_random.Random):
elif version == 2 and isinstance(a, (str, bytes, bytearray)):
if isinstance(a, str):
a = a.encode()
- a = int.from_bytes(a + _sha512(a).digest(), 'big')
+ a = int.from_bytes(a + _sha512(a).digest())
elif not isinstance(a, (type(None), int, float, str, bytes, bytearray)):
raise TypeError('The only supported seed types are: None,\n'
@@ -795,14 +795,14 @@ class SystemRandom(Random):
def random(self):
"""Get the next random number in the range [0.0, 1.0)."""
- return (int.from_bytes(_urandom(7), 'big') >> 3) * RECIP_BPF
+ return (int.from_bytes(_urandom(7)) >> 3) * RECIP_BPF
def getrandbits(self, k):
"""getrandbits(k) -> x. Generates an int with k random bits."""
if k < 0:
raise ValueError('number of bits must be non-negative')
numbytes = (k + 7) // 8 # bits / 8 and rounded up
- x = int.from_bytes(_urandom(numbytes), 'big')
+ x = int.from_bytes(_urandom(numbytes))
return x >> (numbytes * 8 - k) # trim excess bits
def randbytes(self, n):