summaryrefslogtreecommitdiffstats
path: root/Lib/secrets.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-12-30 05:55:03 (GMT)
committerRaymond Hettinger <python@rcn.com>2016-12-30 05:55:03 (GMT)
commit0ce64323cf6b996360416e6bf0ddca0c544eb8f1 (patch)
tree1629000048c354917b1ebdf2004f83eea1b1d8d3 /Lib/secrets.py
parentdfe14c462de137311eafdd80feb1e08b31b9485a (diff)
parente9ee207622f0f78e31b8277ccb9eaa895ea3472d (diff)
downloadcpython-0ce64323cf6b996360416e6bf0ddca0c544eb8f1.zip
cpython-0ce64323cf6b996360416e6bf0ddca0c544eb8f1.tar.gz
cpython-0ce64323cf6b996360416e6bf0ddca0c544eb8f1.tar.bz2
merge
Diffstat (limited to 'Lib/secrets.py')
-rw-r--r--Lib/secrets.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/secrets.py b/Lib/secrets.py
index 27fa450..1304342 100644
--- a/Lib/secrets.py
+++ b/Lib/secrets.py
@@ -26,6 +26,8 @@ choice = _sysrand.choice
def randbelow(exclusive_upper_bound):
"""Return a random int in the range [0, n)."""
+ if exclusive_upper_bound <= 0:
+ raise ValueError("Upper bound must be positive.")
return _sysrand._randbelow(exclusive_upper_bound)
DEFAULT_ENTROPY = 32 # number of bytes to return by default