summaryrefslogtreecommitdiff
path: root/Lib/secrets.py
diff options
context:
space:
mode:
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 27fa4503d7..130434229e 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