summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/random.py b/Lib/random.py
index b21dee8..1f5be45 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -355,7 +355,10 @@ class Random(_random.Random):
"""
u = self.random()
- c = 0.5 if mode is None else (mode - low) / (high - low)
+ try:
+ c = 0.5 if mode is None else (mode - low) / (high - low)
+ except ZeroDivisionError:
+ return low
if u > c:
u = 1.0 - u
c = 1.0 - c