Skip to content

Commit 0bf7c14

Browse files
committed
Helpful error in bizarre circumstances
Closes #3361.
1 parent ba65b74 commit 0bf7c14

File tree

1 file changed

+10
-1
lines changed
  • hypothesis-python/src/hypothesis/strategies/_internal

1 file changed

+10
-1
lines changed

hypothesis-python/src/hypothesis/strategies/_internal/numbers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,16 @@ def __init__(
206206
):
207207
super().__init__()
208208
assert isinstance(allow_nan, bool)
209-
assert smallest_nonzero_magnitude > 0.0
209+
assert smallest_nonzero_magnitude >= 0.0, "programmer error if this is negative"
210+
if smallest_nonzero_magnitude == 0.0: # pragma: no cover
211+
raise FloatingPointError(
212+
"Got allow_subnormal=True, but we can't represent subnormal floats "
213+
"right now, in violation of the IEEE-754 floating-point "
214+
"specification. This is usually because something was compiled with "
215+
"-ffast-math or a similar option, which sets global processor state. "
216+
"See https://simonbyrne.github.io/notes/fastmath/ for a more detailed "
217+
"writeup - and good luck!"
218+
)
210219
self.min_value = min_value
211220
self.max_value = max_value
212221
self.allow_nan = allow_nan

0 commit comments

Comments
 (0)