-
-
Notifications
You must be signed in to change notification settings - Fork 36.8k
random.binomialvariate() can raise ZeroDivisionError when random() returns 0.0 #154001
Copy link
Copy link
Closed
Closed
Copy link
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
Bug description:
random.binomialvariate()can raiseZeroDivisionErrorwhenrandom()returns0.0in one of the paths.Repro with a mock that forces
random()to return zero:From what I've seen, it looks like the chance of
randomreturning zero is about1 in 2^53... But still, zero is a valid result and custom generators may return it more often.CPython versions tested on:
3.12, 3.13, 3.14, 3.15
Operating systems tested on:
macOS
Linked PRs
binomialvariate#154004