One function

Number in alecthomas/voluptuous

The author described this change as Raise Invalid for Infinity/NaN input to Number validator (#542). It counts as a record because the check below fails on the code as it stood at 73237e901 and passes on 44593ce7c, with nothing else changed between the two runs.

Fix saved2026-07-11
Sharing licenceBSD-3-Clause · COPYING
Change size+2 3

What the code was meant to do, written into the code itself as a docstring

Verify the number of digits that are present in the number(Precision), and the decimal places(Scale). :raises Invalid: If the value does not match the provided Precision and Scale.

The change

7878 if isinstance(exp, int):
7979 return (len(decimal_num.as_tuple().digits), -exp, decimal_num)
8080 else:
81- # TODO: handle infinity and NaN
82- # raise Invalid(self.msg or 'Value has no precision')
83- raise TypeError("infinity and NaN have no precision")
81+ # Infinity/NaN have no precision; report as Invalid, not a raw TypeError.
82+ raise Invalid(self.msg or 'Value must be a number enclosed with string')

The check that tells the two apart

failpass·voluptuous/tests/tests.py::test_number_validation_with_infinity_and_nan

Check file voluptuous/tests/tests.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it73237e9014f53da32fd6f90630976f5e8279b420
Broken version dated2026-07-06
Modulevoluptuous.validators
Units changedNumber
Fingerprint16d9fd6c8d3f73f1
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in alecthomas/voluptuous