diff options
author | Raymond Hettinger <python@rcn.com> | 2014-05-26 00:28:38 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2014-05-26 00:28:38 (GMT) |
commit | d58a0b6876bf574c93f60896e0c61fd687febe16 (patch) | |
tree | aa169db54bf7ae793c4bde74d74058733332352e /Lib/random.py | |
parent | c738874024106d28d7ce244cf9410cfc33246776 (diff) | |
parent | 978c6abced7f129a66c39135139e60b3e0fa4e0b (diff) | |
download | cpython-d58a0b6876bf574c93f60896e0c61fd687febe16.zip cpython-d58a0b6876bf574c93f60896e0c61fd687febe16.tar.gz cpython-d58a0b6876bf574c93f60896e0c61fd687febe16.tar.bz2 |
merge
Diffstat (limited to 'Lib/random.py')
-rw-r--r-- | Lib/random.py | 5 |
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 |